foundations_ext

Crates.iofoundations_ext
lib.rsfoundations_ext
version0.0.4
sourcesrc
created_at2024-10-29 23:55:56.793528
updated_at2024-11-07 22:40:46.435686
descriptionFoundation extensions published from the ewe_platform but usable by all
homepage
repositoryhttps://github.com/ewe-studios/ewe_platform
max_upload_size
id1427762
size36,530
Ewetumo Alexander (influx6)

documentation

README

FoundationsExt

An extension crate that provides varying trait extensions for different libraries and utilities. The goal is to have a central place for where such extensions can live without being specifically tied down to the ewe_platform namespace.

Crates

serde_ext

Provides useful extensions for the serde crate, it takes inspiration from the value-ext crate by Jeremy Chone.

If you've read Data Oriented Programming or have used kotlin and love the ease of interacting with basic data structures like maps and list then this will be super familiar.

I have taking inspiration and code from value-ext crate and expanded support for toml based Value types as well to make it super-easy to work with such raw types.

  • JSON
use serde_json::json;
use foundations_ext::serde_ext::DynamicValueExt;
use foundations_ext::serde_ext::JsonValueExt;

let mut value = json!({"tokens": 3, "hello": {"word": "hello"}});

// get a copy of the value
let actual_value: String = value.d_get("/happy/word")?;

// take the value in the path thereby removing from map
let content: String = value.d_take("/hello/word")?;

// add a value into map
value.d_insert("/happy/word", "hello")?;

value.d_walk(|tree, key| {
    // do something
    true
});

  • TOML
use toml::toml;
use foundations_ext::serde_ext::DynamicValueExt;
use foundations_ext::serde_ext::TomlValueExt;

let mut value = toml::Value::Table(toml! {
    token=3

    [hello]
    word = "hello"

    [hello.wreckage]
    where = "londo"
});

// get a copy of the value
let actual_value: String = value.d_get("/happy/word")?;

// take the value in the path thereby removing from map
let content: String = value.d_take("/hello/word")?;

// add a value into map
value.d_insert("/happy/word", "hello")?;

value.d_walk(|tree, key| {
    // do something
    true
});

Inspirations

Commit count: 237

cargo fmt