diff --git a/.editorconfig b/.editorconfig index a49691e..f03fbee 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,5 @@ indent_size = 2 indent_size = 4 [*.dart] indent_size = 2 +[*.rs] +indent_size = 4 diff --git a/templates/Rust2.0/.gitignore b/templates/Rust2.0/.gitignore new file mode 100644 index 0000000..a9d37c5 --- /dev/null +++ b/templates/Rust2.0/.gitignore @@ -0,0 +1,2 @@ +target +Cargo.lock diff --git a/templates/Rust2.0/Cargo.toml b/templates/Rust2.0/Cargo.toml new file mode 100644 index 0000000..603aa7b --- /dev/null +++ b/templates/Rust2.0/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "__name__" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +int-enum = "0.5.0" +serde = { version = "1.0.147", features = ["derive"] } +serde_json = "1.0.88" +threadpool = "1.8.1" +nanoid = "0.4.0" +tokio = { version = "1.22.0", features = ["full"] } + diff --git a/templates/Rust2.0/src/lib.rs b/templates/Rust2.0/src/lib.rs new file mode 100644 index 0000000..c669dc5 --- /dev/null +++ b/templates/Rust2.0/src/lib.rs @@ -0,0 +1,44 @@ +use nanoid::nanoid; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::boxed::Box; +use std::collections::HashMap; +use std::error::Error; +use std::marker::PhantomData; +use std::marker::Send; +use std::sync::mpsc::{Receiver, Sender}; +use std::sync::{Arc, Mutex}; +use threadpool::ThreadPool; + +pub type Result = std::result::Result>; + +#[derive(Serialize, Deserialize)] +pub struct JRPCRequest { + pub jsonrpc: String, + pub id: Option, + pub method: String, + pub params: Value, +} + +#[derive(Serialize, Deserialize)] +pub struct JRPCError { + pub code: i64, + pub message: String, + pub data: Value, +} + +#[derive(Serialize, Deserialize)] +pub struct JRPCResult { + pub jsonrpc: String, + pub id: String, + pub result: Value, + pub error: Option, +} + +struct JRPCServer {} + +impl JRPCServer { + fn handle(&self) -> () {} +} + +struct JRPCServerService {}