Build Status

bridge.rs

Prima bridge pattern implementation for rust

Example

```rust use prima_bridge::prelude::*; use serde::Deserialize;

[derive(Deserialize)]

struct DeserializableData { test: String }

// using we make sure that Bridge get instantiated only once fn bridge() -> &'static Bridge { static BRIDGE: OnceCell = OnceCell::new(); BRIDGE.getorinit(|| Bridge::new("https://prima.it/api")) }

// Do not use expect in production! It will cause runtime errors. Use Result. pub fn fetchdata() -> YourResult { Request::get(bridge()) .send()? .getdata(&["nested", "selector"])? // response is {"nested": {"selector": {"data": "test"}}} }
```

To understand this example you should know: - once_cell library providing the cell type - Rust error handling to use ? and convert it to a custom error type. See for example thiserror