diff --git a/README.md b/README.md index d27b9e0..95052ef 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Methods on services are defined using callbacks. While this is fine for simple s It offers a higher-level abstraction over the underlying protocol, making it easier to use and understand by providing a cleaner more structured way to define services by leveraging Rust's powerful macro system, something similar to [rocket.rs](https://rocket.rs/) but for SOME/IP. # Example -Here's a simple example of defining a service and method using smip: +Let's look at a simple "Hello World" example using smip. ```rust use smip::{Runtime, RuntimeConfig, Service}; @@ -63,18 +63,13 @@ struct MyService { #[smip::methods_impl] impl MyService { - // Method that adds whatever value it receives to x - // Expects u32 in request - // Returns u32 in response + #[smip_method(id = 1)] fn add(&mut self, value: u32) -> u32 { self.x += value; self.x } - - // Method that sends a string - // Expects nothing in request - // Returns String in response + #[smip_method(id = 2)] fn hello(&self) -> String { "Hello World!".to_string() @@ -98,6 +93,8 @@ A service is represented by a struct, `MyService` in this case, with a `service` SOME/IP methods are just rust methods with a special `smip_method` attribute to indicate its id. Whatever you pass as an argument to your method is parsed automatically from the payload, and whatever you return from it serialized into a response and sent back. All of these need to be in a special impl block marked with a `methods_impl` attribute for the framework to recognize them. +There are two methods + A `Runtime` needs to be created using a `RuntimeConfig` which which take care of creating and running all of your services. After adding all your services to the `Runtime`, call `runtime.run()` to start all the services.