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

pub struct Connection { /* 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.

Initialization

There is two way to initialize Connection

  • Default value
use arangors::connection::Connection;
let conn: Connection = Default::default();

Methods

impl Connection[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
  • validate_server in response header is not ArangoDB

pub fn establish<S: Into<String>>(
    arango_url: S,
    auth: Auth
) -> Result<Connection, Error>
[src]

The most trivial way to establish a connection to arangoDB server. Users have to build a Auth object themselves. The recommended way to establish connection is to use the functions that specify the authentication methods:

  • establish_without_auth
  • establish_basic_auth
  • establish_jwt

The most secure way to connect to a arangoDB server is via JWT token authentication, along with TLS encryption.

The connection is establish in the following steps:

  1. validate if it is a arangoDB server at the given base url
  2. set authentication in header
  3. build a http client that holds authentication tokens
  4. construct databases objects for later use

pub fn establish_without_auth<S: Into<String>>(
    arango_url: S
) -> Result<Connection, Error>
[src]

pub fn establish_basic_auth<S: Into<String>>(
    arango_url: S,
    username: S,
    password: S
) -> Result<Connection, Error>
[src]

pub fn establish_jwt<S: Into<String>>(
    arango_url: S,
    username: S,
    password: S
) -> Result<Connection, Error>
[src]

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

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

pub fn db(&self, name: &str) -> Option<&Database>[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 get_all_db(&self) -> HashMap<String, &Database>[src]

Get a hashmap of name-reference for all database.

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

pub fn list_all_database(&self) -> Result<Vec<&String>, Error>[src]

List all existing databases in server. As clients may not has the permission to access all the databases, this function only return a Vec<String> instead of a hash map of databases.

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

Get a pointer of current database. Note that this function would make a request to arango server.

Personally speaking, I don't know why we need to know the current database. As we never need to know the database as long as we get the id of collections.

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

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

Drop database with name.

If the database is successfully dropped, return the dropped database. The ownership of the dropped database would be moved out. And the dropped database can no longer be found at self.databases.

pub fn refresh(&mut self) -> Result<&mut Connection, Error>[src]

Refresh the hierarchy of all accessible databases.

This is a expensive method, and all the cached information about this server would be refreshed.

Refresh is done in the following steps:

  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

Note that a Database object caches all the accessible collections.

This function uses the API that is used to retrieve a list of all databases the current user can access to refresh databases. Then each database retrieve a list of available collections.

Trait Implementations

impl Default for Connection[src]

impl Debug for Connection[src]

Auto Trait Implementations

impl Send for Connection

impl Sync for Connection

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

impl<T> Erased for T