[][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::vf;

// build a new action with the builder pattern
let agent = vf::AgentBuilder::default()
    .name("Andrew".to_string())
    .note("His hands are big".to_string())
    .build().unwrap();
assert_eq!(agent.name(), "Andrew");
assert_eq!(agent.note(), &Some("His hands are big".to_string()));
assert_eq!(agent.image(), &None);
// create a new action with a different label
let new_agent = agent.into_builder()
    .note("DOES NOT HAVE SMALL HANDS".to_string())
    .build().unwrap();
assert_eq!(new_agent.name(), "Andrew");
assert_eq!(new_agent.note(), &Some("DOES NOT HAVE SMALL HANDS".to_string()));

Modules

dfc
geo
om2
vf