SRPC

SRPC is a simple RPC system built on top of Sia, designed to be as ergonomic and zero-cost as possible.

A simple example of an SRPC service ```rust

[srpc::rpc] // other options include rpc(mutex), rpc(none)

[derive(Default)]

struct DistributedList { list: Vec }

[srpc::rpc]

impl DistributedList { async fn push(&mut self, value: T) { self.list.push(value); } async fn get(&self, index: usize) -> Option { self.list.get(index).and_then(|val| Some(val.clone())) } async fn remove(&mut self, index: usize) -> T { self.list.remove(index) } } ```

```rust // database async fn main() -> Result<()> { GLOBALROUTE.addservice_at::>("list", Arc::new(RwLock::new(Default::default())))?; let addr = "tcp@127.0.0.1:8080".parse::()?; // listen in the following address addr.bind().await?; std::future::pending().await }

// peer async fn main() -> Result<()> { let addr = "list://tcp@127.0.0.1:8080".parse::()?; let connection = addr.connect().await?; let mut db = connection.client::>(); db.push(1).await?; db.push(5).await?; db.push(6).await?;

let value = db.get(1).await?;
println!("{:?}", value); // index 1 == 5
Ok(())

} ```