Skip to main content

reovim_protocol/
lib.rs

1#![cfg_attr(coverage_nightly, allow(unused_features))]
2#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
3//! Wire protocol types for reovim client-server communication.
4//!
5//! This crate defines the message types and shared data structures
6//! used for communication between the reovim server and its clients (TUI, CLI, GUI).
7//!
8//! # Architecture
9//!
10//! The protocol crate is designed to be:
11//! - **Minimal**: Only serde dependencies (+ tonic/prost with `grpc` feature)
12//! - **Versioned**: Types are organized under version modules (v1, v2, etc.)
13//! - **Shared**: Used by both server and client crates
14//!
15//! # Protocol Versions
16//!
17//! - **v1**: JSON-RPC 2.0 with cell-grid based rendering (default)
18//! - **v2**: gRPC with raw-data model (requires `grpc` feature)
19//!
20//! # Example (v1 JSON-RPC)
21//!
22//! ```
23//! use reovim_protocol::{RpcRequest, methods};
24//!
25//! // Create a typed request
26//! let request = RpcRequest::new(1, methods::STATE_CURSOR, serde_json::json!({}));
27//! ```
28//!
29//! # Example (v2 gRPC)
30//!
31//! ```ignore
32//! // Requires `grpc` feature
33//! use reovim_protocol::v2::buffer_service_client::BufferServiceClient;
34//!
35//! let mut client = BufferServiceClient::connect("http://127.0.0.1:12523").await?;
36//! let response = client.get_raw_content(GetRawContentRequest::default()).await?;
37//! ```
38
39pub mod codec;
40pub mod instance;
41pub mod v1;
42
43/// Protocol v2: gRPC-based raw-data model.
44///
45/// Requires the `grpc` feature to be enabled.
46#[cfg(feature = "grpc")]
47pub mod v2;
48
49// Re-export v1 as the default API (backward compatibility)
50pub use v1::*;