mod client;
mod handle;
mod manager;
mod server;
mod transport;
mod types;
use aranya_runtime::GraphId;
use aranya_util::Addr;
#[cfg(feature = "preview")]
pub(crate) use self::types::HelloSubscription;
pub(super) use self::types::SyncResponse;
pub(crate) use self::{
client::SyncClient, handle::SyncHandle, manager::SyncManager, server::SyncServer,
transport::quic, types::SyncPeer,
};
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub(crate) enum Error {
#[error(transparent)]
Transport(Box<dyn std::error::Error + Send + Sync + 'static>),
#[error(transparent)]
Runtime(#[from] aranya_runtime::SyncError),
#[error(transparent)]
AranyaClient(#[from] aranya_runtime::ClientError),
#[error("postcard failed to de/serialize a message")]
Postcard(#[from] postcard::Error),
#[cfg(feature = "preview")]
#[error("peer sent empty response")]
EmptyResponse,
#[error("failed to collect effects")]
EffectsSink(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("the sync manager has shut down")]
SyncerShutdown,
#[error("received an invalid request")]
InvalidRequest,
#[error("the server indicated a sync error")]
Response(String),
#[error(transparent)]
Bug(#[from] buggy::Bug),
}
impl From<Error> for aranya_daemon_api::Error {
#[inline]
fn from(err: Error) -> Self {
Self::from_err(err)
}
}
impl From<std::convert::Infallible> for Error {
fn from(err: std::convert::Infallible) -> Self {
match err {}
}
}
impl Error {
fn transport(err: impl std::error::Error + Send + Sync + 'static) -> Self {
Self::Transport(Box::new(err))
}
fn is_parallel_finalize(&self) -> bool {
matches!(
self,
Self::AranyaClient(aranya_runtime::ClientError::ParallelFinalize)
)
}
}
type Result<T> = core::result::Result<T, Error>;