Graphs

Struct Graphs 

Source
pub struct Graphs { /* private fields */ }
Expand description

A colection of Graph

Implementations§

Source§

impl Graphs

Source

pub fn persists(&self) -> Result<(), Box<dyn Error>>

👎Deprecated since 0.15.0: please, for good, use save method instead

Saves the current Graphs into a file with the Graphs’s name

Deprecated method; will be removed on ver. 1.0.0
§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();
Source

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);
Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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>
where T: Display + Clone,

Returns a collection of edges that matches a string attribute vertex for some provided vault_name or default when None

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn uniq_relations(&self) -> Vec<String>

Returns an array with the unique relations in the whole Graphs

Source

pub fn len(&self) -> usize

Retrieves the length of the Graphs for whole vault

Source

pub fn len_graphs(&self) -> usize

Retrieves the length of vault

Source

pub fn is_empty(&self) -> bool

Checks if the Graphs vault is empty

Source

pub fn get_mem(&self) -> Result<usize, &'static str>

function to retrieve memory usage by graphs

Source§

impl Graphs

Source

pub fn init(label: &str) -> Self

Initializes a new Graphs element

§Examples
use gruphst::graphs::Graphs;
  
Graphs::init("my graph");
Source

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);
Source

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");
Source

pub fn insert_with(&mut self, name: &str, edge: &Edge)

Creates a new entry on Graphs valut with a Graph

Source

pub fn get_label(&self) -> String

Returns the label or name for the graphs

Source

pub fn set_label(&mut self, label: &str)

Sets the label or name for the graphs

Source

pub fn get_stats(&mut self) -> GraphsStats

Returns the stats for a grpahs the stats are generated

Source

pub fn get_graphs_stats(&self) -> GraphsStats

Returns the GraphsStats object

Source

pub fn get_vaults(&self) -> Result<HashMap<String, Vec<Edge>>, GruPHstError>

Source

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.

Source

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.

Source

pub fn get_edges( &self, vault_name: Option<&str>, ) -> Result<Vec<Edge>, GruPHstError>

Retrieves the collection of edges the default one or by name

Source

pub fn get_uniq_vertices( &self, vault_name: Option<&str>, ) -> Result<Vec<Vertex>, GruPHstError>

Returns a collection with the unique vertices on a vault

Source

pub fn get_uniq_vertices_on_graphs(&self) -> Result<Vec<Vertex>, GruPHstError>

Returns a collection with the unique vertices from all vaults

Source

pub fn update_label(&mut self, label: &str)

Updates the name of the Graphs

Source

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

Source

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

Source

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();

Trait Implementations§

Source§

impl Clone for Graphs

Source§

fn clone(&self) -> Graphs

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Graphs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Graphs

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Graphs

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Graphs

§

impl !RefUnwindSafe for Graphs

§

impl !Send for Graphs

§

impl !Sync for Graphs

§

impl Unpin for Graphs

§

impl !UnwindSafe for Graphs

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,