nu-node/crates/nu-rpc/src/handlers.rs
Mukan Erkin 5430c34d9e feat(nu-node): initial Faz 0 scaffold
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 00:00:26 +03:00

28 lines
1.1 KiB
Rust

// Method dispatch — each handler maps to a nu.rpc.api method name.
// Handlers are stubs; implementation wired in Faz 1.
use crate::types::{JsonRpcRequest, JsonRpcResponse};
pub fn dispatch(req: JsonRpcRequest) -> JsonRpcResponse {
match req.method.as_str() {
"nu_getBlock" => stub(&req, "nu_getBlock"),
"nu_getTx" => stub(&req, "nu_getTx"),
"nu_getAccount" => stub(&req, "nu_getAccount"),
"nu_getStory" => stub(&req, "nu_getStory"),
"nu_getNode" => stub(&req, "nu_getNode"),
"nu_getNft" => stub(&req, "nu_getNft"),
"nu_listStories" => stub(&req, "nu_listStories"),
"nu_listPendingVotes" => stub(&req, "nu_listPendingVotes"),
"nu_sendRawTx" => stub(&req, "nu_sendRawTx"),
"nu_chainInfo" => stub(&req, "nu_chainInfo"),
_ => JsonRpcResponse::err(req.id, -32601, "Method not found".into()),
}
}
fn stub(req: &JsonRpcRequest, method: &str) -> JsonRpcResponse {
JsonRpcResponse::err(
req.id.clone(),
-32000,
format!("{method} not implemented yet"),
)
}