[][src]Struct arangors::connection::GenericConnection

pub struct GenericConnection<C: ClientExt, S = Normal> { /* fields omitted */ }

Connection is the top level API for this crate. It contains a http client, information about authentication, arangodb url.

Implementations

impl<S, C: ClientExt> GenericConnection<C, S>[src]

pub async fn validate_server<'_>(&'_ self) -> Result<(), ClientError>[src]

Validate the server at given arango url

Cast failure::Error if

  • Connection failed
  • SERVER header in response header is not ArangoDB or empty

pub fn get_url(&self) -> &Url[src]

Get url for remote arangoDB server.

pub fn get_session(&self) -> Arc<C>[src]

Get HTTP session.

Users can use this method to get a authorized session to access arbitrary path on arangoDB Server.

TODO This method should only be public in this crate when all features are implemented.

pub async fn db<'_, '_, '_>(
    &'_ self,
    name: &'_ str
) -> Result<Database<'_, C>, ClientError>
[src]

Get database object with name.

Note

this function would make a request to arango server.

pub async fn accessible_databases<'_>(
    &'_ self
) -> Result<HashMap<String, Permission>, ClientError>
[src]

Get a list of accessible database

This function uses the API that is used to retrieve a list of all databases the current user can access.

Note

this function would make a request to arango server.

impl<C: ClientExt> GenericConnection<C, Normal>[src]

pub async fn establish_without_auth<T: Into<String>>(
    arango_url: T
) -> Result<GenericConnection<C, Normal>, ClientError>
[src]

Establish connection to ArangoDB sever without Authentication.

The target server MUST DISABLE authentication for all requests, which should only used for test purpose.

Disable authentication means all operations are performed by root user.

Example:

This example is not tested
use arangors::Connection;

let conn = Connection::establish_without_auth("http://localhost:8529").await.unwrap();

pub async fn establish_basic_auth<'_, '_, '_>(
    arango_url: &'_ str,
    username: &'_ str,
    password: &'_ str
) -> Result<GenericConnection<C, Normal>, ClientError>
[src]

Establish connection to ArangoDB sever with basic auth.

Example:

use arangors::Connection;

let conn = Connection::establish_basic_auth("http://localhost:8529", "username", "password")
    .await
    .unwrap();

pub async fn establish_jwt<'_, '_, '_>(
    arango_url: &'_ str,
    username: &'_ str,
    password: &'_ str
) -> Result<GenericConnection<C, Normal>, ClientError>
[src]

Establish connection to ArangoDB sever with jwt authentication.

Prefered way to interact with arangoDB server.

JWT token expires after 1 month.

Example:

use arangors::Connection;

let conn = Connection::establish_jwt("http://localhost:8529", "username", "password")
    .await
    .unwrap();

pub async fn create_database<'_, '_, '_>(
    &'_ self,
    name: &'_ str
) -> Result<Database<'_, C>, ClientError>
[src]

Create a database via HTTP request and add it into self.databases.

If creation fails, an Error is cast. Otherwise, a bool is returned to indicate whether the database is correctly created.

Example

use arangors::Connection;
let conn = Connection::establish_jwt("http://localhost:8529", "root", "KWNngteTps7XjrNv")
    .await
    .unwrap();
let result = conn.create_database("new_db").await.unwrap();
println!("{:?}", result);

let result = conn.drop_database("new_db").await.unwrap();
println!("{:?}", result);

TODO tweak options on creating database

Note

this function would make a request to arango server.

pub async fn drop_database<'_, '_>(
    &'_ self,
    name: &'_ str
) -> Result<(), ClientError>
[src]

Drop database with name.

Note

this function would make a request to arango server.

pub async fn into_admin(
    self
) -> Result<GenericConnection<C, Admin>, ClientError>
[src]

impl<C: ClientExt> GenericConnection<C, Admin>[src]

Trait Implementations

impl<C: Clone + ClientExt, S: Clone> Clone for GenericConnection<C, S>[src]

impl<C: Debug + ClientExt, S: Debug> Debug for GenericConnection<C, S>[src]

impl<C: ClientExt> From<GenericConnection<C, Admin>> for GenericConnection<C, Normal>[src]

impl<C: ClientExt> From<GenericConnection<C, Normal>> for GenericConnection<C, Admin>[src]

Auto Trait Implementations

impl<C, S> RefUnwindSafe for GenericConnection<C, S> where
    C: RefUnwindSafe,
    S: RefUnwindSafe

impl<C, S> Send for GenericConnection<C, S> where
    C: Send,
    S: Send

impl<C, S> Sync for GenericConnection<C, S> where
    C: Send,
    S: Sync

impl<C, S> Unpin for GenericConnection<C, S> where
    S: Unpin

impl<C, S> UnwindSafe for GenericConnection<C, S> where
    C: RefUnwindSafe,
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.