[][src]Crate vf_rs

A set of ValueFlows structs and utils auto-generated from the JSON schema.

The structs defined use the same names as the title field in the restecpive schema. Enums are also defined for enum types and are namespaced with the corresponding struct. For instance, the Action struct lives under action::Action and has an enum field label that uses an enum type define under action::Label. The organization of this project closely ties in the with schema itself.

The structs exported have builder structs defined for them using the wonderful derive_builder crate. So Action also has a corresponding ActionBuilder struct. Builder structs use the "owned" pattern, meaning the builder methods consume the builder and return a new instance on each call. Given an existing Action struct instance, you can call myaction.into_builder() to convert (consume) it into an ActionBuilder, which makes immutable updates fairly easy.

This library defines getters and setters for the provided structs via the getset crate. It's important to note that by default, only getters are defined. If you want setters, you can compiled with the feature getset_setters and if you want mutable getters, use getset_getmut. This allows side-stepping some of the enforced functional nature of the library if you find that sort of thing obnoxious.

use vf_rs::action;

// build a new action with the builder pattern
let action = action::ActionBuilder::default()
    .label(action::Label::TransferAllRights)
    .resource_effect(action::ResourceEffect::Increment)
    .build().unwrap();
assert_eq!(action.label(), &Some(action::Label::TransferAllRights));
assert_eq!(action.resource_effect(), &action::ResourceEffect::Increment);
// create a new action with a different label
let new_action = action.into_builder()
    .label(action::Label::TransferCustody)
    .build().unwrap();
assert_eq!(new_action.label(), &Some(action::Label::TransferCustody));
assert_eq!(new_action.resource_effect(), &action::ResourceEffect::Increment);

Modules

action
agent
agent_relationship
agent_relationship_role
agreement
appreciation
claim
commitment
duration
economic_event
economic_resource
fulfillment
intent
measure
plan
process
process_specification
product_batch
proposal
proposed_intent
proposed_to
recipe_flow
recipe_process
recipe_resource
resource_specification
satisfaction
scenario
scenario_definition
settlement
spatial_thing
unit