laburnum 1.17.1

An LSP framework for building language servers and compilers, powered by an incremental query tree with content-addressed storage, task-based dataflow, and parallel queries.
Documentation
// Copyright Two Neutron Stars Incorporated and contributors
// SPDX-License-Identifier: BlueOak-1.0.0

//! Platform-agnostic endpoint abstraction for IPC.

use {
  super::memory::MemoryTransport,
  std::path::PathBuf,
};

/// Represents an IPC endpoint that can be connected to or listened on.
pub enum Endpoint {
  /// Unix domain socket (macOS, Linux, BSD)
  #[cfg(unix)]
  UnixSocket(PathBuf),

  /// Abstract namespace socket (Linux only, auto-cleanup on process exit)
  #[cfg(target_os = "linux")]
  AbstractSocket(String),

  /// Windows named pipe
  #[cfg(windows)]
  NamedPipe(String),

  /// In-memory transport for testing.
  ///
  /// Uses channels instead of real sockets, allowing tests to run
  /// without creating system resources.
  Memory {
    /// The transport registry that manages connections.
    transport: MemoryTransport,
    /// The endpoint name within this transport.
    name:      String,
  },
}

impl Endpoint {
  /// Create an in-memory endpoint for testing.
  pub fn memory(transport: MemoryTransport, name: impl Into<String>) -> Self {
    Endpoint::Memory {
      transport,
      name: name.into(),
    }
  }
}