ratio-metadata

Crates.ioratio-metadata
lib.rsratio-metadata
version0.2.0
created_at2025-06-06 10:31:32.964646+00
updated_at2025-12-02 15:38:07.527409+00
descriptionRatio's metadata model.
homepagehttps://gitlab.com/ratio-case-os/rust/ratio-case/-/tree/main/ratio-metadata
repositoryhttps://gitlab.com/ratio-case-os/rust/ratio-case.git
max_upload_size
id1702793
size186,805
Tiemen Schuijbroek (TiemenSch)

documentation

README

Ratio Metadata

At Ratio CASE we use a common metadata model throughout our crates and applications for "items" which can be anything. It consists of:

  • An (externally defined) unique ID.
  • A name.
  • A main category or "kind".
  • A set of categorical labels or tags.
  • A set of numerical weights.
  • Any remaining "free-form" annotations as JSON serializable values.

This crate provides a "store" for the metadata side of these things depending on unique keys for objects coming from a user-defined [SlotMap] somewhere else. Internally it uses keys per field identifier to keep track of which object key has which kind, label, weight and so on. Thus, the field "values" are stored exactly twice (for a lookup and reverse lookup), but no more.

Example

use ratio_metadata::{SimpleMetadata, SimpleStore};

let mut store = SimpleStore::new();

// Create a blank entry using the default.
let blank = SimpleMetadata::default();
let blank_id = blank.id;

// insertion based on field names, though there are rather little.
let blank_key = store.insert(blank);

// Populate an entry using the builder pattern.
let foo = SimpleMetadata::builder().name("Foo").kind("foo-like").build();
let foo_id = foo.id;
let foo_key = store.insert(foo);

// Just a trivial check.
assert_ne!(blank_key, foo_key);

Changelog

This repository keeps a CHANGELOG.md according to the recommendations by Keep a Changelog.

Contributions

Contributions are welcome! By submitting a contribution, you agree to license your work under the terms of the Mozilla Public License 2.0. Please ensure that your contributions adhere to the existing code style and include appropriate tests and documentation where applicable.

To get started:

  1. Fork the repo
  2. Create a new branch
  3. Make your changes
  4. Make sure you run just fix to adhere to the project's formatting
  5. Submit a merge request with a clear description of the changes

Licensing

This project is licensed under the Mozilla Public License 2.0. You are free to use, modify, and distribute this code, provided that any files you modify or create that are based on MPL-licensed files also remain under the MPL. You must include a copy of the license with the source and make the source code available when distributing binaries.

See the LICENSE file for the full license text.

Code examples both in the docstrings and rendered documentation thereof are free to use!

At Ratio, we are huge supporters of open-source code and the open-source community. In our Python projects we usually strive to use one of the (L)GPL flavors. These are difficult to pair with compiled codebases, however, which is where we see the MPL-2.0 as a great fit for our open-source Rust efforts. It's a weak copyleft license that just protects the source as it is written and encourages changes to the crate's source to be published accordingly. It's sort of "automagically" implied and done right when cargo would pull in the source files to build with, as (the mentioning of) the license is included in the header of each file, and any binaries you generate with them are not of our concern from a distribution perspective.

Enjoy the code!

Commit count: 176

cargo fmt