[][src]Trait g1_common::Connection

pub trait Connection: Send + Sync {
    type Error: Error;
    fn create_atom<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<Atom, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn delete_atom<'life0, 'async_trait>(
        &'life0 self,
        atom: Atom
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn create_name<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        atom: Atom,
        ns: &'life1 str,
        title: &'life2 str,
        upsert: bool
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
fn delete_name<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ns: &'life1 str,
        title: &'life2 str
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
fn create_edge<'life0, 'life1, 'async_trait>(
        &'life0 self,
        from: Atom,
        to: Atom,
        label: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn delete_edge<'life0, 'life1, 'async_trait>(
        &'life0 self,
        from: Atom,
        to: Atom,
        label: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn create_tag<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        atom: Atom,
        key: &'life1 str,
        value: &'life2 str,
        upsert: bool
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
fn delete_tag<'life0, 'life1, 'async_trait>(
        &'life0 self,
        atom: Atom,
        key: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn create_blob<'life0, 'life1, 'async_trait>(
        &'life0 self,
        atom: Atom,
        kind: &'life1 str,
        mime: Mime,
        hash: Hash,
        upsert: bool
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn delete_blob<'life0, 'life1, 'async_trait>(
        &'life0 self,
        atom: Atom,
        kind: &'life1 str,
        mime: Mime
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
fn fetch_blob<'life0, 'async_trait>(
        &'life0 self,
        hash: Hash
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Bytes, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn store_blob<'life0, 'async_trait>(
        &'life0 self,
        data: Pin<Box<dyn Stream<Item = Result<Bytes, Self::Error>> + Send + 'static>>
    ) -> Pin<Box<dyn Future<Output = Result<Hash, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        limit: Option<usize>,
        query: &'life1 NamelessQuery
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Arc<str>>>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; fn query_all<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 NamelessQuery
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Arc<str>>>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... }
fn query_first<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 NamelessQuery
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Arc<str>>>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... }
fn query_has_results<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 NamelessQuery
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } }

The basic interface to a G1 server. This exposes all the operations which must be atomic without transactions.

Associated Types

type Error: Error

The error returned by operations on this connection.

Loading content...

Required methods

fn create_atom<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<Atom, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Creates a new atom in the database, returning it.

fn delete_atom<'life0, 'async_trait>(
    &'life0 self,
    atom: Atom
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Deletes any names referring to an atom, all edges going to or from it, any tags attached to it, and any blobs attached to it.

Note that the atom itself is not deleted, so create_atom will not reuse it. At some point, an operation to do this may exist, but note that doing so will break useful properties for most operations.

fn create_name<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    atom: Atom,
    ns: &'life1 str,
    title: &'life2 str,
    upsert: bool
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 

Creates a new name for an atom.

If the name already exists, it is an error unless upsert is true, in which case the existing name will be deleted.

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

Deletes a name.

Returns whether the name existed prior to the call.

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

Creates a new edge between two atoms.

Returns true if an edge already exists with the same endpoints and label.

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

Deletes the edge with the given endpoints and label.

Returns whether the edge existed prior to the call.

fn create_tag<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    atom: Atom,
    key: &'life1 str,
    value: &'life2 str,
    upsert: bool
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 

Creates a tag attached to an atom with the given key and value.

If a tag with the given key already exists on the atom, it is an error unless upsert is true, in which case the existing value will be replaced by the given one.

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

Deletes the tag with the given key from the given atom.

Returns whether the tag existed prior to the call.

fn create_blob<'life0, 'life1, 'async_trait>(
    &'life0 self,
    atom: Atom,
    kind: &'life1 str,
    mime: Mime,
    hash: Hash,
    upsert: bool
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Creates a blob attached to an atom with the given kind, MIME type, and hash.

If a blob with the given kind and MIME type already exists on the atom, it is an error unless upsert is true, in which case the existing hash will be replaced by the given ones.

fn delete_blob<'life0, 'life1, 'async_trait>(
    &'life0 self,
    atom: Atom,
    kind: &'life1 str,
    mime: Mime
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Deletes the blob with the given kind and MIME type from the given atom.

Returns whether the blob existed prior to the call.

fn fetch_blob<'life0, 'async_trait>(
    &'life0 self,
    hash: Hash
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Bytes, Self::Error>> + Send>>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Fetches a blob from the server by its hash.

fn store_blob<'life0, 'async_trait>(
    &'life0 self,
    data: Pin<Box<dyn Stream<Item = Result<Bytes, Self::Error>> + Send + 'static>>
) -> Pin<Box<dyn Future<Output = Result<Hash, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Stores a blob on the server, returning its hash.

fn query<'life0, 'life1, 'async_trait>(
    &'life0 self,
    limit: Option<usize>,
    query: &'life1 NamelessQuery
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Arc<str>>>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Performs a query, returning multiple results (at most limit).

Loading content...

Provided methods

fn query_all<'life0, 'life1, 'async_trait>(
    &'life0 self,
    query: &'life1 NamelessQuery
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Arc<str>>>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Performs a query, returning all results.

fn query_first<'life0, 'life1, 'async_trait>(
    &'life0 self,
    query: &'life1 NamelessQuery
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Arc<str>>>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Performs a query, returning at most one result.

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

Performs a query, returning whether it had results.

Note that the default implementation can be inefficient.

Loading content...

Implementors

Loading content...