Skip to content

Commit

Permalink
Update wording in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Ax9DTW committed Jun 5, 2024
1 parent faad004 commit 5a53926
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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()
Expand All @@ -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.
Expand Down

0 comments on commit 5a53926

Please sign in to comment.