NetworkFacade

Struct NetworkFacade 

Source
pub struct NetworkFacade {
Show 18 fields pub node: NetworkNode, pub semantic_dht: Option<Arc<RwLock<SemanticDht>>>, pub gossipsub: Option<Arc<RwLock<GossipSubManager>>>, pub geo_router: Option<Arc<RwLock<GeoRouter>>>, pub quality_predictor: Option<Arc<RwLock<QualityPredictor>>>, pub peer_selector: Option<Arc<RwLock<PeerSelector>>>, pub multipath_quic: Option<Arc<RwLock<MultipathQuicManager>>>, pub tor_manager: Option<Arc<RwLock<TorManager>>>, pub bandwidth_throttle: Option<Arc<RwLock<BandwidthThrottle>>>, pub adaptive_polling: Option<Arc<RwLock<AdaptivePolling>>>, pub background_mode: Option<Arc<RwLock<BackgroundModeManager>>>, pub offline_queue: Option<Arc<RwLock<OfflineQueue>>>, pub memory_monitor: Option<Arc<RwLock<MemoryMonitor>>>, pub network_monitor: Option<Arc<RwLock<NetworkMonitor>>>, pub query_batcher: Option<Arc<RwLock<QueryBatcher>>>, pub peer_store: Arc<RwLock<PeerStore>>, pub dht_manager: Arc<RwLock<DhtManager>>, pub dht_provider_registry: Arc<RwLock<DhtProviderRegistry>>,
}
Expand description

High-level network facade integrating all modules

Fields§

§node: NetworkNode

Core network node

§semantic_dht: Option<Arc<RwLock<SemanticDht>>>

Optional modules

§gossipsub: Option<Arc<RwLock<GossipSubManager>>>§geo_router: Option<Arc<RwLock<GeoRouter>>>§quality_predictor: Option<Arc<RwLock<QualityPredictor>>>§peer_selector: Option<Arc<RwLock<PeerSelector>>>§multipath_quic: Option<Arc<RwLock<MultipathQuicManager>>>§tor_manager: Option<Arc<RwLock<TorManager>>>§bandwidth_throttle: Option<Arc<RwLock<BandwidthThrottle>>>§adaptive_polling: Option<Arc<RwLock<AdaptivePolling>>>§background_mode: Option<Arc<RwLock<BackgroundModeManager>>>§offline_queue: Option<Arc<RwLock<OfflineQueue>>>§memory_monitor: Option<Arc<RwLock<MemoryMonitor>>>§network_monitor: Option<Arc<RwLock<NetworkMonitor>>>§query_batcher: Option<Arc<RwLock<QueryBatcher>>>§peer_store: Arc<RwLock<PeerStore>>

Always-available supporting modules

§dht_manager: Arc<RwLock<DhtManager>>§dht_provider_registry: Arc<RwLock<DhtProviderRegistry>>

Implementations§

Source§

impl NetworkFacade

Source

pub fn new(config: NetworkConfig) -> Result<Self>

Create a new network facade with default configuration

Source

pub async fn start(&mut self) -> Result<()>

Start the network node and all enabled modules

Source

pub async fn stop(&mut self) -> Result<()>

Stop the network node and all modules

Source

pub fn peer_id(&self) -> PeerId

Get peer ID

Source

pub fn connected_peers(&self) -> Vec<PeerId>

Get connected peers

Source

pub async fn connect(&mut self, addr: Multiaddr) -> Result<()>

Connect to a peer

Source

pub async fn disconnect(&mut self, peer_id: PeerId) -> Result<()>

Disconnect from a peer

Source

pub async fn provide(&mut self, cid: &Cid) -> Result<()>

Provide content to the DHT

Source

pub async fn find_providers(&mut self, cid: &Cid) -> Result<()>

Find providers for content

Source

pub fn get_health(&self) -> NetworkHealthSummary

Get network health summary

Source

pub fn is_healthy(&self) -> bool

Check if network is healthy

Source

pub fn peer_count(&self) -> usize

Get peer count

Source

pub fn is_connected_to(&self, peer_id: &PeerId) -> bool

Check if connected to peer

Source

pub fn bytes_sent(&self) -> u64

Get bytes sent

Source

pub fn bytes_received(&self) -> u64

Get bytes received

Source

pub async fn with_tor_manager( &mut self, config: TorConfig, ) -> Result<(), TorError>

Add a Tor manager after creation (requires async initialization)

Perform semantic search using vector embeddings (requires semantic_dht)

§Returns

Returns an error if semantic DHT is not enabled

Source

pub fn index_content( &self, cid: Cid, embedding: Vec<f32>, namespace: NamespaceId, ) -> Result<()>

Index content with semantic embedding (requires semantic_dht)

Source

pub fn register_semantic_namespace( &self, namespace: NamespaceId, dimension: usize, ) -> Result<()>

Register a semantic namespace (requires semantic_dht)

Source

pub fn subscribe(&self, topic: &str) -> Result<()>

Subscribe to a topic (requires gossipsub)

Source

pub fn unsubscribe(&self, topic: &str) -> Result<()>

Unsubscribe from a topic (requires gossipsub)

Source

pub fn publish(&self, topic: &str, data: Vec<u8>) -> Result<MessageId>

Publish a message to a topic (requires gossipsub)

Source

pub fn subscribed_topics(&self) -> Result<Vec<String>>

Get subscribed topics (requires gossipsub)

Source

pub fn find_nearby_peers(&self, location: GeoLocation) -> Result<Vec<PeerId>>

Find nearby peers based on geographic location (requires geo_routing)

Source

pub fn set_peer_location( &self, peer_id: PeerId, location: GeoLocation, ) -> Result<()>

Set location for a peer (requires geo_routing)

Source

pub fn get_best_peers( &self, peers: &[PeerId], count: usize, ) -> Result<Vec<PeerId>>

Get best quality peers for content transfer (requires quality_predictor)

Source

pub fn select_optimal_peers( &self, criteria: &SelectionCriteria, ) -> Result<Vec<PeerId>>

Select optimal peers (requires peer_selector)

Source

pub fn get_network_stats(&self) -> NetworkStats

Get comprehensive network statistics

Source

pub fn get_module_status(&self) -> ModuleStatus

Get detailed module status

Source

pub fn get_memory_stats(&self) -> Result<MemoryStats>

Get memory usage statistics (requires memory_monitor)

Source

pub async fn connect_batch(&mut self, addrs: Vec<Multiaddr>) -> Vec<Result<()>>

Connect to multiple peers concurrently

Source

pub async fn provide_batch(&mut self, cids: Vec<Cid>) -> Vec<Result<()>>

Announce multiple CIDs to the DHT

Source

pub async fn find_providers_batch(&mut self, cids: Vec<Cid>) -> Vec<Result<()>>

Find providers for multiple CIDs

Source

pub fn is_module_enabled(&self, module: &str) -> bool

Check if a specific module is enabled

Source

pub fn enabled_modules(&self) -> Vec<String>

Get list of enabled module names

Source

pub fn summary(&self) -> String

Get human-readable summary of the network facade configuration

Auto Trait Implementations§

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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