https://github.com/initerworker/struct_mapping
StructMapping is a library for create string-based accessors/mutators Rust data structure.
https://github.com/initerworker/struct_mapping
Last synced: about 1 year ago
JSON representation
StructMapping is a library for create string-based accessors/mutators Rust data structure.
- Host: GitHub
- URL: https://github.com/initerworker/struct_mapping
- Owner: IniterWorker
- License: apache-2.0
- Created: 2022-09-26T03:50:21.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-09T00:06:45.000Z (over 3 years ago)
- Last Synced: 2025-03-25T18:12:37.337Z (about 1 year ago)
- Language: Rust
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# StructMapping
__StructMapping is a library for generating string-based accessors/mutators Rust data structure.__
## Work In Progress
- [ ] Clean-Up
- [ ] Pipeline
- [ ] Publish Crate/Cargo
---
## StructMapping in action
Click to show Cargo.toml.
```toml
[dependencies]
# The core APIs
struct_mapping = { version = "1.0", features = ["derive"] }
```
```rust
use struct_mapping::{StructMapping, ToStructMappingField};
fn main() {
#[derive(Default)]
struct DeepTestStruct {}
#[derive(StructMapping, Default)]
struct TestStruct {
#[struct_mapping(rename = "jimmy", alias = "jian_yang")]
jian: u32,
#[struct_mapping(skip)]
#[allow(dead_code)]
deep: DeepTestStruct,
}
let mut ex = TestStruct::default();
// print "0"
println!("{}", ex.sm_get("jimmy").unwrap());
ex.sm_set("jimmy", "128").unwrap();
// print "128"
println!("{}", ex.sm_get("jimmy").unwrap());
// print ["jimmy", "jian_yang"]
println!("{:?}", TestStruct::sm_list());
}
```
## License
Licensed under either of Apache License, Version
2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in struct_mapping by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.