eagle/tests/mod.rs

48 lines
1.3 KiB
Rust
Raw Normal View History

2024-06-19 23:25:45 +02:00
/*
2024-06-19 23:27:10 +02:00
Eagle - A library for easy communication in full-stack Rust applications
2024-06-19 23:25:45 +02:00
Copyright (c) 2024 KodiCraft
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use eagle::Protocol;
#[derive(Protocol)]
enum TestProtocol {
Addition((i32, i32), i32),
SomeKindOfQuestion(String, i32),
ThisRespondsWithAString(i32, String),
Void((), ()),
2024-06-19 23:25:45 +02:00
}
struct DummyServer;
impl TestProtocolServer for DummyServer {
fn some_kind_of_question(&mut self, question: String) -> i32 {
question.len() as i32
}
2024-06-20 12:52:42 +02:00
fn addition(&mut self, a: i32, b: i32) -> i32 {
a + b
2024-06-19 23:25:45 +02:00
}
fn this_responds_with_a_string(&mut self, arg: i32) -> String {
format!("The number is {}", arg)
}
fn void(&mut self) {
println!("Void function called!")
}
2024-06-19 23:25:45 +02:00
}
fn main() {}