7 releases

0.0.5 Nov 13, 2025
0.0.4 Nov 1, 2025
0.0.3 Oct 25, 2025
0.0.2 Sep 30, 2025

#27 in #compiler-plugin

MIT license

460KB
9K SLoC

bora - api Documentation

Hello, and welcome to the bora API documentation!

This API documentation is highly technical and is purely a reference.

Depend on bora in Cargo.toml:

[dependencies]
bora = "0.0.1"

Note that development versions, tagged with -dev, are not published and need to be specified as [git dependencies].

use deboa::errors::DeboaError;
use deboa_bora::bora;
use vamo::Vamo;

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(())
}

Disabled features can be selectively enabled in Cargo.toml:

[dependencies]
bora = { version = "0.0.1", features = ["tokio_rt", "http1", "http2"] }
vamo = { version = "0.0.1" }
deboa-extras = { version = "0.0.1" }

Bora

bora (also "let's go" in portuguese) is a macro to generate api clients for vamo.

Install

cargo add bora

Features

  • json
  • xml
  • msgpack

Usage

use deboa::errors::DeboaError;
use bora::bora;
use vamo::Vamo;

#[derive(Deserialize, Debug)]
pub struct Post {
    pub id: u32,
    pub title: String,
}

#[bora(
    api(
        get(name="get_by_id", path="/posts/<id:i32>", res_body=Post, format="json")
    )
)]
pub struct PostService;

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);

Ok(())

Notes

It is not possible to use the same name for different operations. Please keep struct names unique and in separate modules if possible.

License

MIT

Author

Rogerio Pereira Araujo rogerio.araujo@gmail.com

Dependencies

~18–26MB
~378K SLoC