open-net 0.3.5

A cross-platform async networking library for Rust with HTTP and WebSocket clients, network status monitoring, configurable retries, WebSocket reconnection and heartbeats, and managed client lifecycles. Reuse common networking infrastructure across applications to avoid repeated implementation and debugging, helping save development time and AI coding tokens.
Documentation
use super::managed_http_client::ManagedHttpClientInner;
use crate::api::http::http_client::HttpClient;
use std::sync::Arc;

/// Registration state for an HTTP client owned by an [`OpenNetInner`].
///
/// The HTTP registry deliberately has its own slot type.  WebSocket clients
/// have worker-thread ownership and shutdown semantics that are different from
/// the HTTP lanes, so sharing the WebSocket slot would couple the two
/// protocols' lifecycles.
pub(super) enum HttpClientSlot {
    Creating,
    Ready(HttpClient),
    Closing(HttpClient),
    Managed(Arc<ManagedHttpClientInner>),
}

impl HttpClientSlot {
    pub(super) fn into_client(self) -> Option<HttpClient> {
        match self {
            Self::Ready(client) | Self::Closing(client) => Some(client),
            Self::Creating | Self::Managed(_) => None,
        }
    }
}