rest

Attribute Macro rest 

Source
#[rest]
Expand description

A macro to simply programm a REST-wrapper.

ยงExample

This example also includes a explanation on what is happening.

// The macro will automatically generate the needed `struct` including internal data. Do not
// explicitly write the struct.
#[rest]
impl Bahn {
    // Every function will have this format:
    // - `async`.
    // - Name can be freely chosen.
    // - Arguments `&self` and any other things needed to build the request.
    // - Return a `Result` with either the resulting type you want or `rrw::Error` the type of
    // the error can be freely customized.
    async fn location(
        &self, location: &LocationQuery
    ) -> Result<Vec<Location>, Error<StandardRestError>> {
        // Return a `RestRequest`. Do not return what is acually wanted by the function, it
        // will be automatically generated for you.
        RestRequest::<&LocationQuery, ()>::get("/locations").query(location)
    }
}