Welcome to Valu3 - the ultimate, flexible, and powerful library for manipulating diverse data types in your Rust projects. Say goodbye to the complexity of handling numbers, strings, arrays, objects, and datetime values. Valu3 is here to make your life easier!
Valu3 is designed to make data manipulation tasks in Rust a breeze. By combining a wide range of features and a consistent API, it simplifies data handling in Rust projects while maximizing productivity.
Join the Valu3 revolution and experience the future of data manipulation in Rust! π
β‘ Get Started with Valu3 Today! β‘
Here are some examples of how to use the Valu3:
use valu3::prelude::*;
let string_value = "hello".to_value();
let number_value = 42.to_value();
let boolean_value = true.to_value();
let null_value = Value::Null;
let undefined_value = Value::Undefined;
let mut datetime_value = DateTime::from("2023-04-05T00:00:00Z").to_value();
string_value.as_string();
number_value.get_i32();
assert_eq!(boolean_value, true);
assert_eq!(null_value, Value::Null);
assert_eq!(undefined_value, Value::Undefined);
datetime_value.add_days(1);
To start using the Valu3 in your Rust project, simply add the following line to your Cargo.toml
file:
[dependencies]
valu3 = "0.1"
Then, you can import the library in your code like this:
use valu3::prelude::*;
//...
let pi = 3.14.to_value();
Valu3 natively has conversions for famous data types like json, yaml and xml. Furthermore with valu3-derive
you are able to transform struct
to Value
by applying the to_value()
method generated by the ToValue
derive macros. This is an example on converting struct
to Value
and Value
to other payload data types.
use valu3::prelude:*;
#[derive(ToValue, FromValue, Default)]
struct MyStruct {
id: u32,
name: String,
tags: Vec<String>
}
fn main(){
let my_struct = MyStruct::default();
let value = my_struct.to_value();
assert_eq!(my_struct, MyStruct::from_value(value));
}
If your focus is only on using Valu3
for conversion only, use the ToJson
, ToYaml
or ToXml
macros.
use valu3::prelude:*;
#[derive(ToJson, Default)]
struct MyStruct {
id: u32,
name: String,
tags: Vec<String>
}
fn main(){
let my_struct = MyStruct::default();
let json = my_struct.to_json();
println!("{}", json); // print json string
}
Vale3
is able to recognize a payload string, identify and convert it to Value
, follow the example:
use valu3::prelude:*;
fn main(){
let boolean = Value::payload_to_value("true").unwrap();
let float = Value::payload_to_value("3.14").unwrap();
let json = Value::payload_to_value(r#"{"item": 3.14}"#).unwrap();
let array = Value::payload_to_value(r#"[1,2,3]"#).unwrap();
let null = Value::payload_to_value("null").unwrap();
let string = Value::payload_to_value(r#""123""#).unwrap();
assert_eq!(boolean, true.to_value());
assert_eq!(float, 3.14.to_value());
assert_eq!(json, Value::from(vec![("item", 3.14)]));
assert_eq!(array, vec![1, 2, 3].to_value());
assert_eq!(null, Value::Null);
assert_eq!(string, "123".to_value());
}
If you find a bug or have a suggestion for a new feature, please open an issue on the GitHub repository.
If you would like to contribute to the project, please feel free to submit a pull request. Before submitting a pull request, please make sure that your code adheres to the projectβs style guidelines and passes all tests.
~ Weβre constantly working to improve and expand the capabilities of Valu3, making it even more powerful and versatile.
By keeping track of the projectβs progress, you can stay informed about new features in development and planned improvements. This will allow you to make the most of Valu3 in your Rust projects and prepare for future updates.
Our commitment is to make Valu3 the ultimate data manipulation solution in Rust. Your input is invaluable! Feel free to join the discussions, share your ideas, and contribute to the project as it evolves.
Join us in the ongoing journey to refine and expand Valu3! π
This project is licensed under the Apache 2.0 License. See the LICENSE file for more information.