udp 10.2.4

A lightweight and efficient Rust library for building UDP servers with request-response handling.
Documentation
use super::*;

/// Represents the internal, mutable state of the UDP server.
///
/// This struct consolidates all the core components required for the server to operate,
/// including configuration, hooks, and task panic hooks for extending functionality.
/// It is not intended to be used directly by end-users, but rather wrapped within the `Server` struct
/// for thread-safe access.
///
/// Accessors are generated by `#[derive(Data)]`; unused setters (and the unused
/// mutable getter for `read_error`) are skipped to avoid dead code.
#[derive(Clone, Data)]
pub(crate) struct ServerData {
    /// Stores the server's configuration settings, such as address, port, and buffer size.
    #[set(skip)]
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(super) server_config: ServerConfigData,
    /// A collection of request hooks that are invoked for each incoming request.
    #[set(skip)]
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(super) hook: ServerHookList,
    /// A collection of task panic hooks that are invoked when a panic occurs during request processing.
    #[set(skip)]
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(super) task_panic: ServerHookList,
    /// The read error hooks for server operations.
    #[get_mut(skip)]
    #[set(skip)]
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(super) read_error: ServerHookList,
}

/// The primary server structure that provides a thread-safe interface to the server's state.
///
/// This struct acts as a public-facing wrapper around an `Arc<RwLock<ServerData>>`.
/// It allows multiple parts of the application to safely share and modify the server's
/// configuration and state across different threads and asynchronous tasks.
#[derive(Clone)]
pub struct Server(pub(super) ArcRwLock<ServerData>);