#hal #resources #serde #serialization #serde-json #rustic #spec

rustic_hal

A rust library for creating Hal representations of resources, based on serde

4 releases

Uses old Rust 2015

0.2.0 Feb 28, 2019
0.1.3 Nov 19, 2018
0.1.2 Nov 19, 2018
0.1.1 Oct 24, 2016
0.1.0 Oct 24, 2016

#889 in Encoding

MIT/Apache

27KB
561 lines

Rustic Hal

A simple library for serializing (and deserializing coming soon) resources following the HAL Spec

Clippy Linting Result Build Status

Usage

On stable rust (>= 1.15)

Add the dependency to your Cargo.toml:


[dependencies]
rustic_hal="0.2"
serde="1.0"
serde_json="1.0"
serde_derive="1.0"

and to use:


extern crate rustic_hal;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;

use rustic_hal::*;
use serde_json::to_string;

#[derive(Serialize)]
pub struct MyResource {
    pub test: String,
}

fn main() {
    let mr = MyResource {
        test: "Hello, World!".to_string(),
    };
    let hal_res = HalResource::new(mr).with_link("self", "/api/myresource/0");
    println!("json representation: {:?}", to_string(&hal_res));
}

Documentation

see https://pduval.github.io/rustic_hal/rustic_hal/ for the cargo-doc pages.

Credits

This library is heavily inspired by (read copied from) the hal-rs library by Herman J. Radtke III.

Dependencies

~0.7–1.4MB
~32K SLoC