Skip to main content

corsa/
lib.rs

1//! Top-level facade crate for the `corsa` workspace.
2//!
3//! This crate re-exports the building blocks used to talk to `typescript-go`
4//! over stdio:
5//!
6//! - [`api`] for the tsgo API bindings
7//! - [`jsonrpc`] for stdio JSON-RPC framing and transport
8//! - [`lsp`] for LSP clients and virtual-document overlays
9//! - [`orchestrator`] for local orchestration plus optional experimental
10//!   distributed helpers
11//! - [`observability`] for structured runtime events
12//! - [`runtime`] for the lightweight in-house executor
13//! - [`utils`] for shared type-text and checker-adjacent helpers
14//!
15//! # Examples
16//!
17//! ```
18//! use corsa::{
19//!     jsonrpc::RequestId,
20//!     lsp::{VirtualChange, VirtualDocument},
21//!     runtime::block_on,
22//! };
23//!
24//! let mut document = VirtualDocument::untitled("/demo.ts", "typescript", "const value = 1;")?;
25//! document.apply_changes(&[VirtualChange::replace("const value = 2;")])?;
26//! assert_eq!(document.text, "const value = 2;");
27//!
28//! let request_id = RequestId::integer(7);
29//! assert_eq!(request_id.to_string(), "7");
30//!
31//! let value = block_on(async { 21 * 2 });
32//! assert_eq!(value, 42);
33//! # Ok::<(), corsa::CorsaError>(())
34//! ```
35
36/// Re-exports the tsgo stdio API bindings.
37pub mod api {
38    pub use corsa_client::*;
39}
40
41/// Re-exports shared error types.
42pub mod error {
43    pub use corsa_core::{Result, RpcResponseError, TsgoError, TsgoError as CorsaError};
44}
45
46/// Re-exports performance-oriented building blocks such as `CompactString`.
47pub mod fast {
48    pub use corsa_core::fast::*;
49}
50
51/// Re-exports JSON-RPC transport primitives.
52pub mod jsonrpc {
53    pub use corsa_jsonrpc::*;
54}
55
56/// Re-exports LSP clients, overlays, and virtual document helpers.
57pub mod lsp {
58    pub use corsa_lsp::*;
59}
60
61/// Re-exports structured operational events used across the workspace.
62pub mod observability {
63    pub use corsa_core::{
64        SharedObserver, TsgoEvent, TsgoEvent as CorsaEvent, TsgoObserver,
65        TsgoObserver as CorsaObserver,
66    };
67}
68
69/// Re-exports client orchestration and replicated-state helpers.
70pub mod orchestrator {
71    pub use corsa_orchestrator::{ApiOrchestrator, ApiOrchestratorConfig, ApiOrchestratorStats};
72    #[cfg(feature = "experimental-distributed")]
73    pub use corsa_orchestrator::{
74        DistributedApiOrchestrator, RaftCluster, RaftRole, ReplicatedCacheEntry, ReplicatedCommand,
75        ReplicatedSnapshot, ReplicatedState,
76    };
77}
78
79/// Re-exports process spawning primitives.
80pub mod process {
81    pub use corsa_core::{AsyncChildGuard, TsgoCommand, TsgoCommand as CorsaCommand};
82}
83
84/// Re-exports the lightweight in-house runtime.
85pub mod runtime {
86    pub use corsa_runtime::*;
87}
88
89/// Re-exports shared pure utility helpers.
90pub mod utils {
91    pub use corsa_core::utils::*;
92}
93
94pub use corsa_core::{
95    Result, SharedObserver, TsgoError, TsgoError as CorsaError, TsgoEvent, TsgoEvent as CorsaEvent,
96    TsgoObserver, TsgoObserver as CorsaObserver,
97};