cdumay_context 1.0.1

A Rust Library for Context Manipulation and Export
Documentation

cdumay_context

License: BSD-3-Clause cdumay_context on crates.io cdumay_context on docs.rs Source Code Repository

cdumay_context is a lightweight and efficient Rust library designed for manipulating a context and exporting it into various formats. The library provides simple methods to handle structured data and export it in widely used formats like JSON, TOML, and YAML.

This makes it an ideal tool for developers working with configuration management, data serialization, or any use case requiring flexible context manipulation.

Features

  • Context Manipulation: Store, modify, and query data within a context object.
  • Multiple Export Formats: Export the context to JSON, TOML, or YAML formats.

Usage

To utilize cdumay_context in your project, follow these steps:

  1. Add Dependencies: To use cdumay_context in your project, add it to your Cargo.toml as a dependency:
[dependencies]
cdumay_context = "0.1"
  1. Define Context: The core feature of cdumay_context is the context. The context acts as a container where you can store key-value pairs of data. Here's how to create and manipulate it:
use cdumay_context::Context;
use serde_value::Value;

fn main() {
    let mut context = Context::new();
    context.insert("name".to_string(), Value::String("John Doe".to_string()));
    context.insert("age".to_string(), Value::U8(30));
    dbg!(&context);
 }
  1. Exporting the Context: cdumay-context allows you to export the context into various formats like JSON, TOML, and YAML. You can use the following methods to serialize the context:
[dependencies]
cdumay-context = {version = "1.0", features = ["json"] }
use cdumay_context::Context;
use serde_value::Value;

fn main() {
    let mut context = Context::new();
    context.insert("name".to_string(), Value::String("John Doe".to_string()));
    context.insert("age".to_string(), Value::U8(30));
    println!("{}", context.to_json(true).unwrap());
 }