Guzzle
This project is an experimental work in progress and the interface may change.
ToDo:
- Check types
- Use attributes instead of getting all fields
- Recurse over objects that also implement the trait
- Open source and release
What problem are we trying to solve?
We're using a Wordpress database which contains non normalised data in "meta" tables. These tables give us data as a set of keys and values that are attached to another object.
For example, a single post in wp_posts may have multiple entries in wp_postmeta such as location_lat
, location_lng
,
author
. We may wish to take those first two location_*
keys and put the values into a Location
struct, but leave
any other keys for use in different structs.
A handy way to do this is to turn the meta data into iterator, then use a filter_map. For example:
Used like this:
let metadata = vec!;
let location = default;
let left_overs = metadata.into_iter.filter_map;
However, we don't want to have to implement the same function over and over. Instead we can use the custom derive
Guzzle
.
let metadata = vec!;
let remaining_data: = test_data
.into_iter
.filter_map
.collect;
assert_eq!;
assert_eq!;
assert_eq!;