//! Gossip/SWIM protocol integration for Chainfire distributed KVS
//!
//! This crate provides:
//! - Node identity for SWIM protocol
//! - Gossip agent with UDP transport
//! - Membership management
//! - Actual state broadcast

pub mod agent;
pub mod broadcast;
pub mod identity;
pub mod membership;
pub mod runtime;

pub use agent::GossipAgent;
pub use broadcast::ActualState;
pub use identity::GossipId;
pub use membership::MembershipChange;
pub use runtime::GossipRuntime;

use thiserror::Error;

/// Gossip protocol errors
#[derive(Error, Debug)]
pub enum GossipError {
    #[error("Failed to bind to address: {0}")]
    BindFailed(String),

    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("Serialization error: {0}")]
    Serialization(String),

    #[error("Invalid identity: {0}")]
    InvalidIdentity(String),

    #[error("Join failed: {0}")]
    JoinFailed(String),
}
