11 releases
| new 0.0.8 | Mar 1, 2026 |
|---|---|
| 0.0.7 | Feb 28, 2026 |
| 0.0.5 | Dec 9, 2025 |
| 0.0.4 | Nov 13, 2025 |
| 0.0.1 | Sep 30, 2025 |
#868 in HTTP client
435KB
8K
SLoC
Vamo Macros
Vamo macros is a collection of macros to make possible use structs as resources to be sent over vamo as client.
Features
- derive macro for resource trait implementation
- bora attribute macro for quick client creation
Install
Either run from command line:
cargo add vamo-macros vamo deboa
Or add to your Cargo.toml:
vamo-macros = "0.0.1"
vamo = "0.0.1"
deboa = "0.0.1"
Usage
Resource macro
use vamo_macros::Resource;
use vamo::{Vamo, ResourceMethod};
#[derive(Resource)]
#[name("posts")]
#[body_type(JsonBody)]
pub struct User {
#[rid]
id: i32,
name: String,
}
let mut vamo = Vamo::new("https://api.example.com")?;
// post
let response = vamo
.create(user)
.await?
.send()
.await?;
// put
vamo.update(user)?
.send()
.await?;
// patch
vamo.edit(user)?
.send()
.await?;
// delete
vamo.remove(user)?
.send()
.await?;
bora macro
use deboa::errors::DeboaError;
use vamo::Vamo;
use vamo_macros::bora;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct Post {
pub id: u32,
pub title: String,
}
#[bora(
api(
get(name="get_all", path="/posts", res_body=Vec<Post>, format="json"),
get(name="get_by_id", path="/posts/<id:i32>", res_body=Post, format="json"),
get(name="query_by_id", path="/posts?<id:i32>", res_body=Vec<Post>, format="json"),
get(name="query_by_title", path="/posts?<id:i32>&<title:&str>", res_body=Vec<Post>, format="json")
)
)]
pub struct PostService;
#[tokio::main]
async fn main() -> Result<()> {
let client = Vamo::new("https://jsonplaceholder.typicode.com")?;
let mut post_service = PostService::new(client);
let post = post_service.get_by_id(1).await?;
println!("id...: {}", post.id);
println!("title: {}", post.title);
assert_eq!(post.id, 1);
Ok(())
}
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
License
MIT
Authors
Dependencies
~17–36MB
~440K SLoC