Prepare work on Rust2.0 with async/tokio support

This commit is contained in:
Fabian Stamm 2022-12-11 23:37:08 +01:00
parent f301b583cb
commit 890b903f04
4 changed files with 63 additions and 0 deletions

View File

@ -13,3 +13,5 @@ indent_size = 2
indent_size = 4
[*.dart]
indent_size = 2
[*.rs]
indent_size = 4

2
templates/Rust2.0/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
target
Cargo.lock

View File

@ -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"] }

View File

@ -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<T> = std::result::Result<T, Box<dyn Error>>;
#[derive(Serialize, Deserialize)]
pub struct JRPCRequest {
pub jsonrpc: String,
pub id: Option<String>,
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<JRPCError>,
}
struct JRPCServer {}
impl JRPCServer {
fn handle(&self) -> () {}
}
struct JRPCServerService {}