hyperlane-core 23.2.0

A lightweight, high-performance, and cross-platform Rust HTTP server library built on Tokio. It simplifies modern web service development by providing built-in support for middleware, WebSocket, Server-Sent Events (SSE), and raw TCP communication. With a unified and ergonomic API across Windows, Linux, and MacOS, it enables developers to build robust, scalable, and event-driven network applications with minimal overhead and maximum flexibility.
Documentation
use super::*;

/// Unregisters a [`Hook::factory`] inline initializer when its handler `Arc` is dropped.
pub(crate) struct InlineHookGuard {
    /// Pointer address of the enclosing [`ServerHookHandler`] `Arc` payload.
    pub(crate) key: Arc<AtomicUsize>,
}

/// Stack-pinned future that runs a [`ServerHook`] inline without heap allocation when it fits.
pub(crate) struct InlineHookCall<'a> {
    /// The stream passed to the hook.
    pub(super) stream: &'a mut Stream,
    /// The request context passed to the hook.
    pub(super) ctx: &'a mut Context,
    /// Monomorphized initializer for the concrete hook type.
    pub(super) init: InlineInitFn,
    /// Current lifecycle state of the future in `storage`.
    pub(super) state: InlinePollState,
    /// Aligned inline storage for the pinned hook future.
    pub(super) storage: MaybeUninit<[usize; INLINE_FUTURE_WORDS]>,
    /// Prevents moving the future after pinning.
    pub(super) _pinned: PhantomPinned,
}

/// Immutable per-server dispatch table compiled once when [`Server::run`] starts.
#[derive(Clone)]
pub(crate) struct CompiledPipeline {
    /// Static exact-match routes.
    pub(super) static_routes: HashMapXxHash3_64<String, CompiledHook>,
    /// Minimum byte length among registered static route paths (`usize::MAX` when empty).
    pub(super) min_static_len: usize,
    /// Maximum byte length among registered static route paths (`0` when empty).
    pub(super) max_static_len: usize,
    /// Dynamic parameter routes indexed directly by segment count.
    pub(super) dynamic_routes: CompiledPatternBuckets,
    /// Whether any dynamic routes are registered.
    pub(super) has_dynamic: bool,
    /// Regex routes indexed directly by segment count.
    pub(super) regex_routes: CompiledPatternBuckets,
    /// Tail-regex routes that can match paths with equal or more segments.
    pub(super) regex_tail_routes: CompiledTailRegexRoutes,
    /// Whether any regex routes are registered.
    pub(super) has_regex: bool,
    /// Request middleware chain in registration order.
    pub(super) request_middleware: Vec<CompiledHook>,
    /// Response middleware chain in registration order.
    pub(super) response_middleware: Vec<CompiledHook>,
}