Trait apache_age::tokio::AgeClient

source ·
pub trait AgeClient {
    // Required methods
    fn connect_age<'life0, 'async_trait, T>(
        params: &'life0 str,
        tls_mode: T
    ) -> Pin<Box<dyn Future<Output = Result<(Client, JoinHandle<()>), Error>> + Send + 'async_trait>>
       where T: MakeTlsConnect<Socket> + 'static + Send + 'async_trait,
             T::TlsConnect: Send,
             T::Stream: Send,
             <T::TlsConnect as TlsConnect<Socket>>::Future: Send,
             'life0: 'async_trait;
    fn constraint<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        graph: &'life1 str,
        label: &'life2 str,
        name: &'life3 str,
        constraint_text: &'life4 str
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn unique_index<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        graph: &'life1 str,
        label: &'life2 str,
        name: &'life3 str,
        field: &'life4 str
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn required_constraint<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        graph: &'life1 str,
        label: &'life2 str,
        name: &'life3 str,
        field: &'life4 str
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn create_graph<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn drop_graph<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn graph_exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn execute_cypher<'life0, 'life1, 'life2, 'async_trait, T>(
        &'life0 self,
        graph: &'life1 str,
        cypher: &'life2 str,
        agtype: Option<AgType<T>>
    ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
       where T: Serialize + Debug + Sync + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn query_cypher<'life0, 'life1, 'life2, 'async_trait, T>(
        &'life0 self,
        graph: &'life1 str,
        cypher: &'life2 str,
        agtype: Option<AgType<T>>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, Error>> + Send + 'async_trait>>
       where T: Serialize + Debug + Sync + Send + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn prepare_cypher<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        graph: &'life1 str,
        cypher: &'life2 str,
        use_arg: bool
    ) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Handles connecting, configuring and querying graph dbs within postgres instance

Required Methods§

source

fn connect_age<'life0, 'async_trait, T>( params: &'life0 str, tls_mode: T ) -> Pin<Box<dyn Future<Output = Result<(Client, JoinHandle<()>), Error>> + Send + 'async_trait>>
where T: MakeTlsConnect<Socket> + 'static + Send + 'async_trait, T::TlsConnect: Send, T::Stream: Send, <T::TlsConnect as TlsConnect<Socket>>::Future: Send, 'life0: 'async_trait,

source

fn constraint<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, graph: &'life1 str, label: &'life2 str, name: &'life3 str, constraint_text: &'life4 str ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Create a new constraint for the certain label within graph

IMPORTANT: At least one object has to be created with a certain label

source

fn unique_index<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, graph: &'life1 str, label: &'life2 str, name: &'life3 str, field: &'life4 str ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Create unique index for the certain field for the label within graph

IMPORTANT: At least one object has to be created with a certain label

source

fn required_constraint<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, graph: &'life1 str, label: &'life2 str, name: &'life3 str, field: &'life4 str ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

source

fn create_graph<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source

fn drop_graph<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source

fn graph_exists<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source

fn execute_cypher<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, graph: &'life1 str, cypher: &'life2 str, agtype: Option<AgType<T>> ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where T: Serialize + Debug + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Execute cypher query, without any rows to be retured

source

fn query_cypher<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, graph: &'life1 str, cypher: &'life2 str, agtype: Option<AgType<T>> ) -> Pin<Box<dyn Future<Output = Result<Vec<Row>, Error>> + Send + 'async_trait>>
where T: Serialize + Debug + Sync + Send + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Query cypher for a single agtype (in a format of json)

IMPORTANT: You need to return result of the query as a map

Example:

MATCH (n: Person) WHERE n.name = 'Alfred' RETURN {name: n.name, surname: n.surname}
source

fn prepare_cypher<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, graph: &'life1 str, cypher: &'life2 str, use_arg: bool ) -> Pin<Box<dyn Future<Output = Result<Statement, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Prepare cypher query for future use

use apache_age::tokio::{AgeClient, Client};
use apache_age::{AgType, NoTls, Vertex};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
struct Day<'a> {
   pub name: &'a str,
   pub is_rainy: bool,
   pub month: u8,
}

unsafe impl<'a> Sync for Day<'a> {}

#[tokio::main]
pub async fn main() {
   let (client, _) = Client::connect_age(
       "host=localhost user=postgres password=passwd port=8081",
       NoTls,
   )
   .await
   .unwrap();

   client.create_graph("prepared_statements").await.unwrap();

   let statement = client
       .prepare_cypher(
           "prepared_statements",
           "CREATE (x: PreparedDay { name: $name, is_rainy: $is_rainy, month: $month })",
           true,
       )
       .await
       .unwrap();

   let day = Day {
       name: "Some day",
       is_rainy: false,
       month: 2,
   };

   client.query(&statement, &[&AgType(day)]).await.unwrap();

   let x = client
       .query_cypher::<()>(
           "prepared_statements",
           "MATCH (x: PreparedDay) RETURN x",
           None,
       )
       .await
       .unwrap();

   let day: Vertex<Day> = x[0].get(0);
   assert_eq!(day.properties().month, 2);
   assert!(!day.properties().is_rainy);
   assert_eq!(day.properties().name, "Some day");

   client.drop_graph("prepared_statements").await.unwrap();
}

Object Safety§

This trait is not object safe.

Implementors§