A generic rust value
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trivernis 5bd25c1fe0
Add support for OsString and PathBuf
2 years ago
derive Add package metadata 2 years ago
src Add support for OsString and PathBuf 2 years ago
tests Add support for OsString and PathBuf 2 years ago
.gitignore Add derive macro for structs 2 years ago
Cargo.toml Add support for OsString and PathBuf 2 years ago
LICENSE Create LICENSE 2 years ago
README.md Add trait implementation for () type 2 years ago

README.md

Rusty Value

This crate adds a RustyValue trait that can be derived for all types (except unions) to create a generic value that represents a rust value. This can be used to implement serialization of types without having to rely on serde.

Usage

The trait RustyValue allows one to create a rusty_value::Value for any type that implements it. This trait can be derived if the derive feature is enabled.


use rusty_value::RustyValue;

#[derive(RustyValue)]
struct MyStruct {
  foo: String,
  bar: u8,
}

fn main() {
  MyStruct {
    foo: "Hello World".to_string(),
    bar: 12,
  }.into_rusty_value();
}

Converting a type into a rusty value cannot fail as rusty_value::RustyValue is able to represent any safe rust data type. The trait RustyValue is already implemented for most std types and can therefore be easily derived.