use std::sync::Arc;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum KitsuneP2pError {
#[error(transparent)]
GhostError(#[from] ghost_actor::GhostError),
#[error(transparent)]
KitsuneError(#[from] kitsune_p2p_types::KitsuneError),
#[error("Routing Space Error: {0:?}")]
RoutingSpaceError(Arc<KitsuneSpace>),
#[error("Routing Agent Error: {0:?}")]
RoutingAgentError(Arc<KitsuneAgent>),
#[error("Decoding Error: {0}")]
DecodingError(Box<str>),
#[error(transparent)]
StdIoError(#[from] std::io::Error),
#[error(transparent)]
Reqwest(#[from] reqwest::Error),
#[error("Bootstrap Error: {0}")]
Bootstrap(Box<str>),
#[error(transparent)]
SystemTime(#[from] std::time::SystemTimeError),
#[error(transparent)]
TryFromInt(#[from] std::num::TryFromIntError),
#[error("Other: {0}")]
Other(Box<dyn std::error::Error + Send + Sync>),
}
pub use crate::actor::KitsuneP2pResult;
impl KitsuneP2pError {
pub fn other(e: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> Self {
Self::Other(e.into())
}
pub fn decoding_error(s: String) -> Self {
Self::DecodingError(s.into_boxed_str())
}
}
impl From<String> for KitsuneP2pError {
fn from(s: String) -> Self {
#[derive(Debug, thiserror::Error)]
struct OtherError(String);
impl std::fmt::Display for OtherError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
KitsuneP2pError::other(OtherError(s))
}
}
impl From<&str> for KitsuneP2pError {
fn from(s: &str) -> Self {
s.to_string().into()
}
}
pub use kitsune_p2p_types::bin_types::*;
pub mod agent_store {
pub use kitsune_p2p_types::agent_info::*;
}
pub mod actor;
pub mod event;
pub(crate) mod gossip;
#[allow(missing_docs)]
pub mod wire;
pub use gossip::GossipModuleType;
pub use kitsune_p2p_types::dht;
pub use kitsune_p2p_types::dht_arc;
#[allow(missing_docs)]
pub mod metrics;