1pub mod behaviour;
2pub mod builder;
3pub mod error;
4pub mod handle;
5pub mod task;
6pub(crate) mod types;
7
8use crate::behaviour::BehaviourEvent;
9use libp2p::identity::Keypair;
10use libp2p::swarm::NetworkBehaviour;
11use libp2p::swarm::{Swarm, SwarmEvent};
12use std::task::{Context, Poll};
13
14pub(crate) type TTaskCallback<B, Ctx, Cmd, Store> =
15 Box<dyn Fn(&mut Swarm<behaviour::Behaviour<B, Store>>, &mut Ctx, Cmd) + 'static + Send>;
16pub(crate) type TEventCallback<B, Ctx, Store> = Box<
17 dyn Fn(&mut Swarm<behaviour::Behaviour<B, Store>>, &mut Ctx, <B as NetworkBehaviour>::ToSwarm)
18 + 'static
19 + Send,
20>;
21pub(crate) type TPollableCallback<B, Ctx, Store> = Box<
22 dyn Fn(&mut Context, &mut Swarm<behaviour::Behaviour<B, Store>>, &mut Ctx) -> Poll<()>
23 + 'static
24 + Send,
25>;
26pub(crate) type TSwarmEventCallback<B, Ctx, Store> = Box<
27 dyn Fn(
28 &mut Swarm<behaviour::Behaviour<B, Store>>,
29 &SwarmEvent<BehaviourEvent<B, Store>>,
30 &mut Ctx,
31 )
32 + 'static
33 + Send,
34>;
35
36pub(crate) type TPreloadCallback<B, Ctx, Store> = Box<
37 dyn FnOnce(&Keypair, &mut Swarm<behaviour::Behaviour<B, Store>>, &mut Ctx) + 'static + Send,
38>;
39
40pub mod dummy {
41 pub use crate::behaviour::dummy::{Behaviour, DummyHandler};
42}
43
44pub mod prelude {
45 use crate::builder::ConnexaBuilder;
46 pub use crate::types::*;
47 pub use libp2p::{Multiaddr, PeerId, Stream, StreamProtocol, multiaddr::Protocol};
48
49 pub use crate::handle::swarm::ConnectionTarget;
50
51 use crate::prelude::peer_store::store::memory::MemoryStore;
52 pub use libp2p::identity;
53
54 pub mod swarm {
55 pub use libp2p::SwarmBuilder;
56 pub use libp2p::swarm::*;
57 }
58
59 pub mod peer_store {
60 pub use crate::behaviour::peer_store::store;
61 }
62
63 #[cfg(feature = "kad")]
64 pub mod dht {
65 pub use crate::handle::dht::{ToOptionalRecordKey, ToRecordKey};
66 pub use libp2p::kad::*;
67 }
68
69 #[cfg(feature = "request-response")]
70 pub mod request_response {
71 pub use crate::handle::request_response::{IntoRequest, OptionalStreamProtocol};
72 pub use libp2p::request_response::{
73 Config, Event, InboundFailure, InboundRequestId, Message, OutboundFailure,
74 OutboundRequestId, ProtocolSupport,
75 };
76 }
77
78 #[cfg(feature = "stream")]
79 pub mod stream {
80 pub use crate::handle::stream::IntoStreamProtocol;
81 pub use libp2p_stream::{Control, IncomingStreams, OpenStreamError};
82 }
83
84 #[cfg(feature = "relay")]
85 pub mod relay {
86 pub mod server {
87 pub use libp2p::relay::{Config, Event, RateLimiter, StatusCode};
89 }
90
91 pub mod client {
92 pub use libp2p::relay::client::Event;
93 }
94 }
95
96 #[cfg(feature = "dcutr")]
97 pub mod dcutr {
98 pub use libp2p::dcutr::{Error, Event};
99 }
100
101 #[cfg(feature = "ping")]
102 pub mod ping {
103 pub use libp2p::ping::{Config, Event, Failure};
104 }
105
106 #[cfg(feature = "identify")]
107 pub mod identify {
108 pub use libp2p::identify::{Config, Event, Info, UpgradeError};
109 }
110
111 #[cfg(feature = "gossipsub")]
112 pub mod gossipsub {
113 pub use crate::handle::gossipsub::IntoTopic as IntoGossipsubTopic;
114 pub use libp2p::gossipsub::{
115 AllowAllSubscriptionFilter, Config, ConfigBuilder, Event, IdentTopic, Message,
116 MessageAcceptance, MessageAuthenticity, MessageId, Sha256Topic, Topic, TopicHash,
117 ValidationMode, Version,
118 };
119 }
120
121 #[cfg(feature = "floodsub")]
122 pub mod floodsub {
123 pub use crate::handle::floodsub::IntoTopic as IntoFloodsubTopic;
124 pub use libp2p::floodsub::{Config, Event, Topic};
125 }
126
127 #[cfg(feature = "rendezvous")]
128 pub mod rendezvous {
129 pub use crate::handle::rendezvous::IntoNamespace;
130 pub use libp2p::rendezvous::{
131 Cookie, ErrorCode, MAX_NAMESPACE, MAX_TTL, MIN_TTL, Namespace, Registration,
132 };
133 }
134
135 #[cfg(feature = "mdns")]
136 #[cfg(not(target_arch = "wasm32"))]
137 pub mod mdns {
138 pub use libp2p::mdns::{Config, Event};
139 }
140
141 #[cfg(feature = "autonat")]
142 pub mod autonat {
143 pub mod v1 {
144 pub use libp2p::autonat::v1::{
145 Config, Event, InboundFailure, InboundProbeError, InboundProbeEvent,
146 };
147 }
148
149 pub mod v2 {
150 pub mod server {
151 pub use libp2p::autonat::v2::server::Event;
152 }
153
154 pub mod client {
155 pub use libp2p::autonat::v2::client::{Config, Event};
156 }
157 }
158 }
159
160 #[cfg(feature = "upnp")]
161 #[cfg(not(target_arch = "wasm32"))]
162 pub mod upnp {
163 pub use libp2p::upnp::Event;
164 }
165
166 pub mod connection_limits {
167 pub use libp2p_connection_limits::{ConnectionLimits, Exceeded};
168 }
169
170 pub mod transport {
171 #[cfg(feature = "dns")]
172 pub mod dns {
173 pub use crate::builder::transport::DnsResolver;
174 }
175 pub use libp2p::core::muxing;
176 pub use libp2p::core::transport;
177 pub use libp2p::core::upgrade;
178 pub use libp2p::core::{ConnectedPoint, Endpoint};
179 #[cfg(feature = "noise")]
180 pub use libp2p::noise;
181 #[cfg(feature = "pnet")]
182 pub use libp2p::pnet;
183 #[cfg(feature = "quic")]
184 #[cfg(not(target_arch = "wasm32"))]
185 pub use libp2p::quic;
186 #[cfg(feature = "tcp")]
187 #[cfg(not(target_arch = "wasm32"))]
188 pub use libp2p::tcp;
189 #[cfg(feature = "websocket")]
190 #[cfg(not(target_arch = "wasm32"))]
191 pub use libp2p::websocket;
192 #[cfg(feature = "yamux")]
193 pub use libp2p::yamux;
194 }
195
196 pub type DefaultConnexaBuilder = ConnexaBuilder<super::dummy::Behaviour, (), (), MemoryStore>;
197}