Building some more necessary structures out of the protocol definition
This commit is contained in:
58
tests/expanded.rs
Normal file
58
tests/expanded.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
#![feature(prelude_import)]
|
||||
#[prelude_import]
|
||||
use std::prelude::rust_2021::*;
|
||||
#[macro_use]
|
||||
extern crate std;
|
||||
use eagle::Protocol;
|
||||
enum TestProtocol {
|
||||
Addition((i32, i32), i32),
|
||||
SomeKindOfQuestion(String, i32),
|
||||
}
|
||||
enum TestProtocolAnswer {
|
||||
addition(i32),
|
||||
some_kind_of_question(i32),
|
||||
}
|
||||
enum TestProtocolQuestion {
|
||||
addition((i32, i32)),
|
||||
some_kind_of_question(String),
|
||||
}
|
||||
enum TestProtocolQuery {
|
||||
addition((i32, i32), Option<i32>),
|
||||
some_kind_of_question(String, Option<i32>),
|
||||
}
|
||||
trait TestProtocolServer {
|
||||
fn addition(&mut self, arg0: i32, arg1: i32) -> i32;
|
||||
fn some_kind_of_question(&mut self, arg: String) -> i32;
|
||||
}
|
||||
struct TestProtocolClient {
|
||||
queries: ::std::collections::HashMap<u64, TestProtocolQuery>,
|
||||
send_queue: tokio::sync::mpsc::Sender<TestProtocolQuestion>,
|
||||
recv_queue: tokio::sync::mpsc::Receiver<TestProtocolAnswer>,
|
||||
}
|
||||
impl TestProtocolClient {
|
||||
pub fn new(
|
||||
send_queue: tokio::sync::mpsc::Sender<TestProtocolQuestion>,
|
||||
recv_queue: tokio::sync::mpsc::Receiver<TestProtocolAnswer>,
|
||||
) -> Self {
|
||||
Self {
|
||||
queries: ::std::collections::HashMap::new(),
|
||||
send_queue,
|
||||
recv_queue,
|
||||
}
|
||||
}
|
||||
pub fn addition(&mut self, arg0: i32, arg1: i32) -> i32 {
|
||||
panic!("not implemented")
|
||||
}
|
||||
pub fn some_kind_of_question(&mut self, arg: String) -> i32 {
|
||||
panic!("not implemented")
|
||||
}
|
||||
}
|
||||
struct DummyServer;
|
||||
impl TestProtocolServer for DummyServer {
|
||||
fn some_kind_of_question(&mut self, question: String) -> i32 {
|
||||
question.len() as i32
|
||||
}
|
||||
fn addition(&mut self, arg0: i32, arg1: i32) -> i32 {
|
||||
panic!("not yet implemented")
|
||||
}
|
||||
}
|
||||
@@ -33,3 +33,5 @@ impl TestProtocolServer for DummyServer {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
Reference in New Issue
Block a user