Crates.io | purp-value-derive |
lib.rs | purp-value-derive |
version | 0.1.0 |
source | src |
created_at | 2023-04-19 01:44:40.21611 |
updated_at | 2023-04-19 01:44:40.21611 |
description | A generic serialization/deserialization/type framework |
homepage | |
repository | https://github.com/14bislab/purp-value |
max_upload_size | |
id | 843113 |
size | 12,386 |
The Purp Value provides a flexible and powerful way to manipulate different types of data in your Rust projects. Whether you need to work with numbers, strings, arrays, objects, or datetime values, the Purp Value has you covered.
Here are some examples of how to use the Purp Value:
use value::{Array, DateTime, Number, Object, StringB, Value};
let string_value = Value::String(StringB::new("hello".to_string()));
let number_value = Value::Number(Number::from(42));
let boolean_value = Value::Boolean(true);
let null_value = Value::Null;
let undefined_value = Value::Undefined;
let mut datetime_value = Value::DateTime(DateTime::from("2023-04-05T00:00:00Z"));
string_value.to_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);
You can also convert your own data types to a Value
enum by implementing the to_value
method. For example:
use value::{Array, DateTime, Number, Object, StringB, Value};
let array = Array::from(vec![Value::Number(Number::from(1)), Value::Number(Number::from(2))]).to_value();
let object = Object::from(vec![("key".to_string(), Value::String(StringB::new("value".to_string())))]).to_value();
let string = StringB::new("hello".to_string()).to_value();
let number = Number::from(42).to_value();
let boolean = true.to_value();
let datetime = DateTime::from("2023-04-05T00:00:00Z").to_value();
To start using the Purp Value in your Rust project, simply add the following line to your Cargo.toml
file:
[dependencies]
value = "0.1"
Then, you can import the library in your code like this:
use value::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.
This project is licensed under the MIT License. See the LICENSE-APACHE or LICENSE-MIT file for more information.