Crates.io | servify |
lib.rs | servify |
version | |
source | src |
created_at | 2024-09-28 08:02:26.554946 |
updated_at | 2024-10-05 04:16:47.78755 |
description | A macro for effortlessly enabling message passing, inter-process communication, HTTP/TCP server functionality, and more with a unified implementation in struct methods. |
homepage | |
repository | https://github.com/pulsuite/servify |
max_upload_size | |
id | 1389879 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A macro for effortlessly enabling message passing, inter-process communication, HTTP/TCP server functionality, and more with a unified implementation in struct methods.
#[servify::service(
impls = [
Counter_increment_and_get,
Counter_get_value,
]
)]
struct Counter {
pub count: u32,
}
#[servify::export]
impl Counter {
fn increment_and_get(&mut self, count: u32) -> u32 {
self.count += count;
self.count
}
fn get_value(&self) -> u32 {
self.count
}
}
#[tokio::test]
async fn count_up() {
let (rx, client) = Counter::initiate_message_passing(32);
tokio::spawn(async move {
Counter::Server { count: 3 }.listen(rx).await;
});
assert_eq!(client.get_value().await, 3);
assert_eq!(client.increment_and_get(5).await, 8);
}
Licensed under either of
Apache License, Version 2.0 (LICENSE-APACHE)
MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.