graph_event 1.1.1

The project is focused on graph nodes that are connected through mutation events.
Documentation
  • Coverage
  • 37.93%
    11 out of 29 items documented4 out of 15 items with examples
  • Size
  • Source code size: 146.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.44 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • patrickfp93/graph_event
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • patrickfp93

Welcome to GraphEvent!

The Graph Event is a Rust crate that is designed to relate states to each other. Each state will be contained in a specific node along with a generic type value. In turn, the nodes connect in two different ways: by notification and observation.

How it works

Notifications

First, any node needs to mark other nodes, as if saying that it will notify them whenever it updates. If the generic type implements PartialEq, it will check if there has been a change in the value that the node carries. If not, the user system will have to notify the node itself that it has indeed been updated.

use  crate::{node::Node};
let  mut  a  =  Node::new(5);
let  b  =  Node::new(10);
let _ =  a.try_mark_for_notification(b.clone(), |a,b| {*b  +=  *a ; true}, crate::util::NotificationPolicy::All);
a.update(11);
assert_eq!(*a,11);
assert_eq!(*b,21);

Notification Policy

Policy Description In Code
ALL Notifies all nodes. NotificationPolicy::All
Less Updated Notifies less updated nodes. NotificationPolicy::LessUpdated
More Updated Notifies more updated nodes. NotificationPolicy::MoreUpdated
Equally Updated Notifies us equally updated. NotificationPolicy::EquallyUpdated
Differently Updated Notifies differently updated nodes. NotificationPolicy::DifferentlyUpdated
Equally Or Less Updated Notifies equally or less updated nodes. NotificationPolicy::Equally Or Less Updated
Equally Or More Updated Notifies equally or more updated nodes. NotificationPolicy::EquallyOrMoreUpdated

Observations

This happens when any node has marked another node and that other node is updated. Then, the relationship/connection between the nodes holds the previous state of the updated node.

Note: However, the observing node only observes if it is demanded.

use  crate::{node::Node};
let  mut  a  =  Node::new(5);
let  mut  b  =  Node::new(10);
let _ =  b.try_mark_for_observation(a.clone(), |a, b| {*b  +=  *a; true });
assert_eq!(*a,5);
a.update(11);
assert_eq!(*a,11);
assert_eq!(*b,10);
b.watch_for_updates();
assert_eq!(*b,21);

Links:

Doc(1.1.1) crate.io