pub struct Graphs { /* private fields */ }Expand description
A colection of Graph
Implementations§
Source§impl Graphs
impl Graphs
Sourcepub fn persists(&self) -> Result<(), Box<dyn Error>>
👎Deprecated since 0.15.0: please, for good, use save method instead
pub fn persists(&self) -> Result<(), Box<dyn Error>>
save method insteadSaves the current Graphs into a file with the Graphs’s name
§Examples
use gruphst::{edge::Edge, vertex::Vertex, graphs::Graphs};
let edge = Edge::create(
&Vertex::new("Sauron"),
"created",
&Vertex::new("One Ring"));
let mut graphs = Graphs::init_with("Middle-earth", &edge);
// will write a file called 'Middle-earth.grphst' with
// the content of the graphs
graphs.persists();Sourcepub fn save(&self, file_path: Option<&str>) -> Result<(), Box<dyn Error>>
pub fn save(&self, file_path: Option<&str>) -> Result<(), Box<dyn Error>>
Saves the current Graphs into a file with the Graphs’s name or in the provided path and failename
§Examples
use gruphst::{edge::Edge, vertex::Vertex, graphs::Graphs};
let edge = Edge::create(
&Vertex::new("Sauron"),
"created",
&Vertex::new("One Ring"));
let mut graphs = Graphs::init_with("Middle-earth", &edge);
// will write a file called 'Middle-earth.grphst' with
// the content of the graphs
graphs.save(None);Sourcepub fn load(file_name: &str) -> Result<Graphs, Box<dyn Error>>
pub fn load(file_name: &str) -> Result<Graphs, Box<dyn Error>>
Loads the persisted Graphs on a file
§Examples
use gruphst::{edge::Edge, vertex::Vertex, graphs::Graphs};
let edge = Edge::create(
&Vertex::new("Sauron"),
"created",
&Vertex::new("One Ring"));
let mut graphs = Graphs::init_with("Middle-earth", &edge);
graphs.save(None);
let loaded_graphs = Graphs::load("Middle-earth.grphst").unwrap();Source§impl Graphs
impl Graphs
Sourcepub fn find_edges_by_relation(
&mut self,
relation_name: &str,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_by_relation( &mut self, relation_name: &str, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of Edges that matches the relation for provided vault or default when None
Sourcepub fn find_edges_by_relations(
&mut self,
relations: Vec<&str>,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_by_relations( &mut self, relations: Vec<&str>, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of Edges elements that matches the relations in the array for provided vault or default when None
Sourcepub fn find_edges_with_vertex_attr_key_like(
&mut self,
attr_k: &str,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_with_vertex_attr_key_like( &mut self, attr_k: &str, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of edges like any attribute vertex key for some provided vault_name or default when None
Sourcepub fn find_edges_with_vertex_attr_key(
&mut self,
attr_k: &str,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_with_vertex_attr_key( &mut self, attr_k: &str, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of edges that matches any attribute vertex by key for some provided vault_name or default when None
Sourcepub fn find_edges_with_vertex_attr_str_key(
&mut self,
attr_k: &str,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_with_vertex_attr_str_key( &mut self, attr_k: &str, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of edges that matches a string attribute vertex by key for some provided vault_name or default when None
Sourcepub fn find_edges_with_vertex_attr_str_key_like(
&mut self,
attr_k: &str,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_with_vertex_attr_str_key_like( &mut self, attr_k: &str, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of edges like string attribute vertex key for some provided vault_name or default when None
Sourcepub fn find_edges_with_vertex_attr_str_equals_to<T>(
&self,
attr_k: &str,
attr_v: T,
vault_name: Option<&str>,
) -> Result<Vec<Edge>, GruPHstError>
pub fn find_edges_with_vertex_attr_str_equals_to<T>( &self, attr_k: &str, attr_v: T, vault_name: Option<&str>, ) -> Result<Vec<Edge>, GruPHstError>
Returns a collection of edges that matches a string attribute vertex for some provided vault_name or default when None
Sourcepub fn find_edges_with_vertex_attr_vec_u8_key(
&mut self,
attr_k: &str,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_with_vertex_attr_vec_u8_key( &mut self, attr_k: &str, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of edges that matches a vector u8 attribute vertex by key for some provided vault_name or default when None
Sourcepub fn find_edges_with_vertex_attr_vec_u8_key_like(
&mut self,
attr_k: &str,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_with_vertex_attr_vec_u8_key_like( &mut self, attr_k: &str, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of edges like vector u8 attribute vertex key for some provided vault_name or default when None
Sourcepub fn find_edges_with_vertex_attr_vec_u8_equals_to(
&mut self,
attr_k: &str,
attr_v: &Vec<u8>,
vault_name: Option<&str>,
) -> Result<Vec<&Edge>, GruPHstError>
pub fn find_edges_with_vertex_attr_vec_u8_equals_to( &mut self, attr_k: &str, attr_v: &Vec<u8>, vault_name: Option<&str>, ) -> Result<Vec<&Edge>, GruPHstError>
Returns a collection of edges where vector u8 attribute value is equals to for some provided vault_name or default when None
Sourcepub fn find_edge_by_id(
&mut self,
id: &str,
vault_name: Option<&str>,
) -> Result<&mut Edge, GruPHstError>
pub fn find_edge_by_id( &mut self, id: &str, vault_name: Option<&str>, ) -> Result<&mut Edge, GruPHstError>
Returns an Edge that provided id matches with Edge Id, or From, To vertices for some provided vault_name or default when None
Sourcepub fn find_edge_by_id_in_graphs(
&mut self,
id: &str,
) -> Result<&mut Edge, GruPHstError>
pub fn find_edge_by_id_in_graphs( &mut self, id: &str, ) -> Result<&mut Edge, GruPHstError>
Find edge by id on any graphs’ vault
Source§impl Graphs
impl Graphs
Sourcepub fn find_vertex_by_id(
&mut self,
id: &str,
vault_name: Option<&str>,
) -> Result<Vertex, GruPHstError>
pub fn find_vertex_by_id( &mut self, id: &str, vault_name: Option<&str>, ) -> Result<Vertex, GruPHstError>
Returns a Vertex that provided id matches with id of From, To vertices for some provided vault_name or default when None
Sourcepub fn find_vertex_by_id_in_graphs(
&mut self,
id: &str,
) -> Result<Vertex, GruPHstError>
pub fn find_vertex_by_id_in_graphs( &mut self, id: &str, ) -> Result<Vertex, GruPHstError>
Returns a Vertex that provided id matches with id of From, To vertices on any graphs’ vault
Sourcepub fn find_vertices_with_relation_in(
&self,
relation_in: &str,
vault_name: Option<&str>,
) -> Result<Vec<Vertex>, GruPHstError>
pub fn find_vertices_with_relation_in( &self, relation_in: &str, vault_name: Option<&str>, ) -> Result<Vec<Vertex>, GruPHstError>
Retrieves all the vertices with incoming relation for some provided vault_name or default when None
Sourcepub fn find_vertices_with_relation_out(
&self,
relation_out: &str,
vault_name: Option<&str>,
) -> Result<Vec<Vertex>, GruPHstError>
pub fn find_vertices_with_relation_out( &self, relation_out: &str, vault_name: Option<&str>, ) -> Result<Vec<Vertex>, GruPHstError>
Retrieves all the vertices with outcoming relation for some provided vault_name or default when None
Source§impl Graphs
impl Graphs
Sourcepub fn uniq_graph_relations(
&self,
graphs_name: Option<&str>,
) -> Result<Vec<String>, GruPHstError>
pub fn uniq_graph_relations( &self, graphs_name: Option<&str>, ) -> Result<Vec<String>, GruPHstError>
Returns an array with the unique relations in the current graph or the one provided
Sourcepub fn uniq_relations(&self) -> Vec<String>
pub fn uniq_relations(&self) -> Vec<String>
Returns an array with the unique relations in the whole Graphs
Sourcepub fn len_graphs(&self) -> usize
pub fn len_graphs(&self) -> usize
Retrieves the length of vault
Source§impl Graphs
impl Graphs
Sourcepub fn init_with(label: &str, vertex: &Edge) -> Self
pub fn init_with(label: &str, vertex: &Edge) -> Self
Initializes a new Graphs element adding a Edge to new vault
§Examples
use gruphst::{edge::Edge, vertex::Vertex, graphs::Graphs};
let edge = Edge::create(
&Vertex::new("Sauron"),
"created",
&Vertex::new("One Ring"));
Graphs::init_with("my graph", &edge);Sourcepub fn insert(&mut self, name: &str)
pub fn insert(&mut self, name: &str)
Creates a new entry on Graphs valut
§Examples
use gruphst::graphs::Graphs;
let mut graphs = Graphs::init("my graphs");
graphs.insert("my other graphs");Sourcepub fn insert_with(&mut self, name: &str, edge: &Edge)
pub fn insert_with(&mut self, name: &str, edge: &Edge)
Creates a new entry on Graphs valut with a Graph
Sourcepub fn get_stats(&mut self) -> GraphsStats
pub fn get_stats(&mut self) -> GraphsStats
Returns the stats for a grpahs the stats are generated
Sourcepub fn get_graphs_stats(&self) -> GraphsStats
pub fn get_graphs_stats(&self) -> GraphsStats
Returns the GraphsStats object
pub fn get_vaults(&self) -> Result<HashMap<String, Vec<Edge>>, GruPHstError>
Sourcepub fn add_edge(&mut self, edge: &Edge, vault_name: Option<&str>)
pub fn add_edge(&mut self, edge: &Edge, vault_name: Option<&str>)
Adds a Edge element to the Graphs’ vault for the provided graphs vault name if does not exists it creates a new entry at vault. If None name is provided, the current one is use for the addition.
Sourcepub fn add_edges(&mut self, edges: &mut Vec<Edge>, vault_name: Option<&str>)
pub fn add_edges(&mut self, edges: &mut Vec<Edge>, vault_name: Option<&str>)
Adds a collection of Edges to the Graphs’ vault for the provided graphs vault name if does not exists it creates a new entry at vault. If None name is provided, the current one is use for the addition.
Sourcepub fn get_edges(
&self,
vault_name: Option<&str>,
) -> Result<Vec<Edge>, GruPHstError>
pub fn get_edges( &self, vault_name: Option<&str>, ) -> Result<Vec<Edge>, GruPHstError>
Retrieves the collection of edges the default one or by name
Sourcepub fn get_uniq_vertices(
&self,
vault_name: Option<&str>,
) -> Result<Vec<Vertex>, GruPHstError>
pub fn get_uniq_vertices( &self, vault_name: Option<&str>, ) -> Result<Vec<Vertex>, GruPHstError>
Returns a collection with the unique vertices on a vault
Sourcepub fn get_uniq_vertices_on_graphs(&self) -> Result<Vec<Vertex>, GruPHstError>
pub fn get_uniq_vertices_on_graphs(&self) -> Result<Vec<Vertex>, GruPHstError>
Returns a collection with the unique vertices from all vaults
Sourcepub fn update_label(&mut self, label: &str)
pub fn update_label(&mut self, label: &str)
Updates the name of the Graphs
Sourcepub fn delete_edge_by_id(
&mut self,
id: String,
vault_name: Option<&str>,
) -> Result<(), GruPHstError>
pub fn delete_edge_by_id( &mut self, id: String, vault_name: Option<&str>, ) -> Result<(), GruPHstError>
Deletes the Edge that matches with the provided id
Sourcepub fn update_graph(
&mut self,
edge_to_update: &Edge,
vault_name: Option<&str>,
) -> Result<(), GruPHstError>
pub fn update_graph( &mut self, edge_to_update: &Edge, vault_name: Option<&str>, ) -> Result<(), GruPHstError>
Updates the Edge on vault with the provided one
Sourcepub fn delete_vault(&mut self, graph_name: &str) -> Result<(), GruPHstError>
pub fn delete_vault(&mut self, graph_name: &str) -> Result<(), GruPHstError>
Removes a graph from the vault
#Examples
use gruphst::graphs::Graphs;
let mut graphs = Graphs::init("graph-one");
assert_eq!(graphs.len_graphs(), 1);
graphs.insert("graph-two");
assert_eq!(graphs.len_graphs(), 2);
graphs.delete_vault("graph-two").unwrap();