Skip to main content

Crate plugx_input

Crate plugx_input 

Source
Expand description

§Plugx Input (work-in-progress)

A simple and flexible data-structure for configuration and state manipulation of plugins.

Package | Documentation | Repository


§Features

FeatureEnables
(none)Core Input type, From conversions, [Display]
serde[Serialize]/[Deserialize], infallible Input::serialize
rkyvBinary archive via Input::to_rkyv_bytes / Input::from_rkyv_bytes

serde or rkyv also exposes error and position for structured deserialize errors.

plugx-input = { version = "1.1", features = ["serde"] }

§Demo

use plugx_input::Input;

let mut map = Input::new_map();
map.map_mut().unwrap().insert("key".into(), Input::from([1, 2, 3]));
let inner_list = map
    .map_mut().unwrap()   // &mut Hashmap<String, Input>
    .get_mut("key")       // Option<&mut Input>
    .unwrap()             // &mut Input (which is a list)
    .list_mut().unwrap(); // &mut Vec<Input>
*inner_list.get_mut(0).unwrap() = 3.14.into();
*inner_list.get_mut(1).unwrap() = true.into();
*inner_list.get_mut(2).unwrap() = "hello world".into();
println!("{map}");
// prints:
// {"key": [3.14, true, "hello world"]}

§To contributors

I ❤️ PR from everyone, and I appreciate your help but before opening a PR, file an issue and describe your feature, fix, etc.

§Modules

ModuleFeatureRole
errorserde or rkyvDeserialize failure types
positionserde or rkyvSource paths in error messages

Modules§

error
Deserialize errors and helpers.
position
Location paths for deserialization errors (e.g. config.toml:7:[server][host]).

Enums§

Input
Dynamically typed value for plugin configuration and runtime state.
InputType
Kind of value stored in Input.