[][src]Struct arangors::connection::Connection

pub struct Connection<S> { /* fields omitted */ }

Connection is the top level API for this crate. It contains a http client, information about auth, arangodb url, and a hash map of the databases Object. The databases Hashmap is construct once connections succeed.

Methods

impl<S> Connection<S>[src]

pub fn validate_server(&self) -> Result<(), Error>[src]

Validate the server at given arango url

Cast failure::Error if

  • Connection failed
  • response code is not 200
  • no SERVER header in response header
  • SERVER header in response header is not ArangoDB

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

Get url for remote arangoDB server.

pub fn get_session(&self) -> Arc<Client>[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 fn db(&self, name: &str) -> Result<Database, Error>[src]

Get database object with name.

This function look up accessible database in cache hash map, and return a reference of database if found.

pub fn accessible_databases(&self) -> Result<HashMap<String, Permission>, Error>[src]

Get a list of accessible database

  1. retrieve the names of all the accessible databases
  2. for each databases, construct a Database object and store them in self.databases for later use

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

impl Connection<Normal>[src]

pub fn establish_without_auth<T: Into<String>>(
    arango_url: T
) -> Result<Connection<Normal>, Error>
[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").unwrap();

pub fn establish_basic_auth(
    arango_url: &str,
    username: &str,
    password: &str
) -> Result<Connection<Normal>, Error>
[src]

Establish connection to ArangoDB sever with basic auth.

Example:

use arangors::Connection;

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

pub fn establish_jwt(
    arango_url: &str,
    username: &str,
    password: &str
) -> Result<Connection<Normal>, Error>
[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").unwrap();

pub fn into_admin(self) -> Result<Connection<Admin>, Error>[src]

impl Connection<Admin>[src]

pub fn create_database(&self, name: &str) -> Result<Database, Error>[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.

TODO tweak options on creating database

pub fn drop_database(&mut self, name: &str) -> Result<(), Error>[src]

Drop database with name.

pub fn into_normal(self) -> Connection<Normal>[src]

Trait Implementations

impl From<Connection<Normal>> for Connection<Admin>[src]

impl From<Connection<Admin>> for Connection<Normal>[src]

impl<S: Debug> Debug for Connection<S>[src]

Auto Trait Implementations

impl<S> Sync for Connection<S> where
    S: Sync

impl<S> Send for Connection<S> where
    S: Send

impl<S> Unpin for Connection<S> where
    S: Unpin

impl<S> !RefUnwindSafe for Connection<S>

impl<S> !UnwindSafe for Connection<S>

Blanket Implementations

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

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

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.

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

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

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

impl<T> Erased for T

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

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