2 unstable releases
0.2.0 | Nov 8, 2024 |
---|---|
0.1.0 | Oct 4, 2024 |
#872 in Encoding
126 downloads per month
31KB
611 lines
Graphex
This library provide few traits to create a tool to explore a pseudo graph.
Traits
- Impl
Node
to allow the node of your graph to be explored. - Impl
Display
to display the result of the exploration.
Faq
Do all the graph must exists in memory ?
No, and this is why it is a pseudo graph.
Node::next
can create node at runtime and return it.
Why not using std::fmt::Display
?
std::fmt::Display
is probably better implemented than graphex::Display
.
However, there is only one impl possible for std::fmt::Display
.
One may want to display different information (as potential key to explore next node) than std::fmt::Display
.
Using two different traits make this possible.
Contributing
Pull requests are welcome !!!
lib.rs
:
Graphex (Grah Explorer) is a small library helper to build command line tool to explore (pseudo) graph.
It mainly defines two traits ([Node] and [Display]) user have to implement for its structs.
- [Node] is for traversing the graph from node to node.
- [Display] is for display the final node at end of exploration.
Few other strucs and functions are defined as helper.
Features
"Serde" support can be added using serde
feature.
It add the Node::serde
method to get a serde value from a [Node].
To avoid any compilation error when a third party project activate the serde
feature on
a project which has not implemented Node::serde
, Node::serde
returns a Option
and a
default implementation returning None
is provided.
However, providing a default implementation prevent the compiler to fail if someone forget to
implement Node::serde
. The feature serde_no_defaul_impl
do not provide a default
implementation and so compiler fails if Node::serde
is not implemented.
!! serde_no_default_impl
MUST NOT be activated in Cargo.toml
. Activate it only temporarly
from command line cargo build --features=serde_no_default_impl
!
Dependencies
~0.3–1MB
~22K SLoC