Download codex-rs/app-server-protocol/src/rpc.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 2.66 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/app-server-protocol/src/rpc.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/app-server-protocol/src/rpc.rs
-
curl -L -o rpc.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/app-server-protocol/src/rpc.rs
2.66 kB
| //! We do not do true JSON-RPC 2.0, as we neither send nor expect the | |
| //! "jsonrpc": "2.0" field. | |
| use crate::JsonSchema; | |
| use crate::TS; | |
| use codex_protocol::protocol::W3cTraceContext; | |
| use serde::Deserialize; | |
| use serde::Serialize; | |
| use std::fmt; | |
| pub const JSONRPC_VERSION: &str = "2.0"; | |
| pub enum RequestId { | |
| String(String), | |
| Integer(i64), | |
| } | |
| impl fmt::Display for RequestId { | |
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| match self { | |
| Self::String(value) => f.write_str(value), | |
| Self::Integer(value) => write!(f, "{value}"), | |
| } | |
| } | |
| } | |
| pub type Result = serde_json::Value; | |
| /// Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent. | |
| pub enum JSONRPCMessage { | |
| Request(JSONRPCRequest), | |
| Notification(JSONRPCNotification), | |
| Response(JSONRPCResponse), | |
| Error(JSONRPCError), | |
| } | |
| /// A request that expects a response. | |
| pub struct JSONRPCRequest { | |
| pub id: RequestId, | |
| pub method: String, | |
| pub params: Option<serde_json::Value>, | |
| /// Optional W3C Trace Context for distributed tracing. | |
| pub trace: Option<W3cTraceContext>, | |
| } | |
| /// A notification which does not expect a response. | |
| pub struct JSONRPCNotification { | |
| pub method: String, | |
| pub params: Option<serde_json::Value>, | |
| } | |
| /// A successful (non-error) response to a request. | |
| pub struct JSONRPCResponse { | |
| pub id: RequestId, | |
| pub result: Result, | |
| } | |
| /// A response to a request that indicates an error occurred. | |
| pub struct JSONRPCError { | |
| pub error: JSONRPCErrorError, | |
| pub id: RequestId, | |
| } | |
| pub struct JSONRPCErrorError { | |
| pub code: i64, | |
| pub data: Option<serde_json::Value>, | |
| pub message: String, | |
| } | |