#![doc = document_features::document_features!()]
#[cfg(feature = "client")]
pub(crate) mod tcp_client;
#[cfg(feature = "client")]
mod buffered_client;
#[cfg(feature = "client")]
pub use {buffered_client::Client, tcp_client::ClientError};
#[cfg(feature = "server")]
mod server;
#[cfg(feature = "server")]
pub use server::{serve, ServerError, ServerOptions};
#[derive(thiserror::Error, Debug)]
pub enum ConnectionError {
#[error("An unknown client tried to connect")]
UnknownClient,
#[error(transparent)]
VersionError(#[from] VersionError),
#[error(transparent)]
SendError(#[from] std::io::Error),
#[error(transparent)]
#[cfg(feature = "server")]
DecodeError(#[from] re_log_encoding::decoder::DecodeError),
#[error("The receiving end of the channel was closed")]
ChannelDisconnected(#[from] re_smart_channel::SendError<re_log_types::LogMsg>),
}
#[derive(thiserror::Error, Debug)]
#[allow(unused)]
pub enum VersionError {
#[error("SDK client is using an older protocol version ({client_version}) than the SDK server ({server_version})")]
ClientIsOlder {
client_version: u16,
server_version: u16,
},
#[error("SDK client is using a newer protocol version ({client_version}) than the SDK server ({server_version})")]
ClientIsNewer {
client_version: u16,
server_version: u16,
},
}
pub const PROTOCOL_VERSION_0: u16 = 0;
pub const PROTOCOL_VERSION_1: u16 = 1;
pub const PROTOCOL_HEADER: &str = "rerun";
pub const DEFAULT_SERVER_PORT: u16 = 9876;
pub fn default_server_addr() -> std::net::SocketAddr {
std::net::SocketAddr::from(([127, 0, 0, 1], DEFAULT_SERVER_PORT))
}
#[allow(clippy::unnecessary_wraps)]
pub fn default_flush_timeout() -> Option<std::time::Duration> {
Some(std::time::Duration::from_secs(2))
}