Skip to content

purp-project/valu3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

99 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Valu3: Unleash the Power of Data Manipulation in Rust πŸš€

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!

crates.io Documentation MSRV MIT or Apache 2.0 licensed Dependency Status Main test codecov downloads

🌟 Key Features

  1. Universal Type Handling: No more juggling with different data types! Valu3's generic type support enables smooth management of all data types under one roof.
  2. Intuitive API: Experience effortless data manipulation with Valu3's user-friendly API, designed to provide consistency across diverse data types.
  3. All-in-One Data Manipulation: Valu3 has it all - numeric, string, object, array, and date/time manipulation. No need to look anywhere else!
  4. Effortless Data Conversion: Convert your data to and from popular formats like JSON, YAML, and XML with ease, thanks to Valu3's built-in support.
  5. Serde Integration: Serialize and deserialize your data seamlessly with Valu3's out-of-the-box integration with the Serde library.
  6. Native Struct Parsing & Validation: Valu3 and Pest join forces to offer native parsing, conversion, and validation of data to structs, ensuring data integrity at every step.
  7. Payload Interpretation & Transformation: Valu3 interprets and transforms payload strings like a champ, handling JSON from HTTP request bodies and more.

πŸ’‘ Why Choose Valu3?

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! ⚑

Examples πŸ‘Ύ

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

Getting Started

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

Structs and Conversions

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

ToJson, ToYaml, ToXml

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
}

Payload

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

Contributing

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.

Upcoming Features: Stay in Sync with the Future of Valu3 🌐

We're constantly working to improve and expand the capabilities of Valu3, making it even more powerful and versatile. Stay updated on the upcoming features and enhancements by visiting our project board on GitHub:

πŸ”— Purp Project Board on GitHub

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! πŸš€

License

This project is licensed under the Apache 2.0 or MIT License. See the LICENSE-APACHE or LICENSE-MIT file for more information.

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages