Struct rings_node::prelude::Swarm
source · pub struct Swarm { /* private fields */ }Expand description
The transports and dht management.
Implementations§
source§impl Swarm
impl Swarm
pub fn did(&self) -> Did
pub fn dht(&self) -> Arc<PeerRing>
pub fn session_manager(&self) -> &SessionManager
pub fn create_message_handler(
self: &Arc<Swarm>,
callback: Option<Box<dyn MessageCallback + Sync + Send + 'static, Global>>,
validator: Option<Box<dyn MessageValidator + Sync + Send + 'static, Global>>
) -> MessageHandler
sourcepub async fn poll_message(
&self
) -> impl Future<Output = Option<MessagePayload<Message>>>
pub async fn poll_message(
&self
) -> impl Future<Output = Option<MessagePayload<Message>>>
This method is required because web-sys components is not Send
which means an async loop cannot running concurrency.
pub async fn iter_messages<'a, 'b>(
&'a self
) -> impl Future<Output = impl Stream<Item = MessagePayload<Message>> + 'b>where
'a: 'b,
pub fn push_pending_transport(
&self,
transport: &Arc<DefaultTransport>
) -> Result<(), Error>
pub fn pop_pending_transport(&self, transport_id: Uuid) -> Result<(), Error>
pub async fn pending_transports(
&self
) -> impl Future<Output = Result<Vec<Arc<DefaultTransport>, Global>, Error>>
pub fn find_pending_transport(
&self,
id: Uuid
) -> Result<Option<Arc<DefaultTransport>>, Error>
pub async fn disconnect(
&self,
did: Did
) -> impl Future<Output = Result<(), Error>>
pub async fn connect(
&self,
did: Did
) -> impl Future<Output = Result<Arc<DefaultTransport>, Error>>
Trait Implementations§
source§impl ChordStorageInterface for Swarm
impl ChordStorageInterface for Swarm
source§fn storage_check_cache<'life0, 'async_trait>(
&'life0 self,
vid: Did
) -> Pin<Box<dyn Future<Output = Option<VirtualNode>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Swarm: 'async_trait,
fn storage_check_cache<'life0, 'async_trait>(
&'life0 self,
vid: Did
) -> Pin<Box<dyn Future<Output = Option<VirtualNode>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Swarm: 'async_trait,
Check local cache
source§fn storage_fetch<'life0, 'async_trait>(
&'life0 self,
vid: Did
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Swarm: 'async_trait,
fn storage_fetch<'life0, 'async_trait>(
&'life0 self,
vid: Did
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Swarm: '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<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Swarm: 'async_trait,
fn storage_store<'life0, 'async_trait>(
&'life0 self,
vnode: VirtualNode
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Swarm: 'async_trait,
Store VirtualNode, TryInto
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, Global>>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, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
append data to Data type virtual node
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, Global>>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, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
append data to Data type virtual node uniquely
source§impl<T> PayloadSender<T> for Swarmwhere
T: Clone + Serialize + DeserializeOwned + Send + Sync + 'static + Debug,
impl<T> PayloadSender<T> for Swarmwhere
T: Clone + Serialize + DeserializeOwned + Send + Sync + 'static + Debug,
fn session_manager(&self) -> &SessionManager
fn do_send_payload<'life0, 'async_trait>(
&'life0 self,
did: Did,
payload: MessagePayload<T>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Swarm: 'async_trait,
fn send_payload<'life0, 'async_trait>(
&'life0 self,
payload: MessagePayload<T>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn send_message<'life0, 'async_trait>(
&'life0 self,
msg: T,
next_hop: Did,
destination: Did
) -> Pin<Box<dyn Future<Output = Result<Uuid, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn send_direct_message<'life0, 'async_trait>(
&'life0 self,
msg: T,
destination: Did
) -> Pin<Box<dyn Future<Output = Result<Uuid, Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn send_report_message<'life0, 'async_trait>(
&'life0 self,
msg: T,
tx_id: Uuid,
relay: MessageRelay
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn forward_payload<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 MessagePayload<T>,
relay: MessageRelay
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
source§impl SubringInterface for Swarm
impl SubringInterface for Swarm
source§fn subring_join<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
fn subring_join<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Swarm: 'async_trait,
add did into current chord subring.
send direct message with JoinSubring type, which will handled by next node.