#command-line #graph-node #display #pseudo #command-line-tool #graph-traversal #serde

graphex

A small library to help creating command line tools exploring pseudo graph

2 unstable releases

0.2.0 Nov 8, 2024
0.1.0 Oct 4, 2024

#912 in Encoding

Download history 149/week @ 2024-10-04 14/week @ 2024-10-11 2/week @ 2024-10-18 3/week @ 2024-11-01 117/week @ 2024-11-08 27/week @ 2024-11-15 25/week @ 2024-11-22

172 downloads per month
Used in jubako

MIT license

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.2–1MB
~21K SLoC