1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! Connecting to an [ArangoDB] server
//!
//! A connector implements the communication layer of the driver. It knows how
//! to talk to an [ArangoDB] server, by using a transport protocol like HTTP or
//! HTTPS and a serialization format like [JSON] or [VelocyPack].
//!
//! The `Connector` trait is defined in the [`rincon_core`] API. This crate
//! provides some default implementations to be used out of the box.
//!
//! Currently there is only one `Connector` implementation provided:
//!
//! * `JsonHttpConnector` : using [JSON] over HTTP/HTTPS
//!
//! but more are planned to be added in the future.
//!
//! # Example
//!
//! Using a `Connector` is straight forward. Here is an example of how to use
//! the `JsonHttpConnector`. Other `Connector`s are used in a similar way.
//!
//! First we create an instance by calling the `new()` function. The `new()`
//! function takes a `DataSource` and a handle of a `reactor::Core` as
//! parameters.
//!
//! The `DataSource` is a data struct that holds the parameters needed to
//! connect to an [ArangoDB] server. It is defined by the [`rincon_core`] API.
//! The `reactor::Core` is taken from the [`tokio-core`] crate.
//!
//! ```rust
//! # extern crate rincon_core;
//! # extern crate rincon_connector;
//! # extern crate tokio_core;
//! use rincon_core::api::connector::Error;
//! use rincon_core::api::datasource::DataSource;
//! use rincon_connector::http::JsonHttpConnector;
//! use tokio_core::reactor::Core;
//! use std::str::FromStr;
//!
//! # fn main() {
//! # let connector = create_connector().unwrap();
//! # }
//!
//! fn create_connector() -> Result<JsonHttpConnector, Error> {
//!
//! let datasource = DataSource::from_str("http://localhost:8529")
//! .expect("invalid URL for datasource")
//! .with_basic_authentication("root", "s3cur3");
//!
//! let mut core = Core::new()?;
//!
//! let connector = JsonHttpConnector::new(datasource, &core.handle());
//! connector
//! }
//! ```
//!
//! The connector we just created is used to execute method calls of the
//! [`rincon_client`] API or is passed to the [`rincon_session`] API dependant
//! on what API you want to use. For more details see the documentation of
//! those crates.
//!
//! TODO: add example on how to use connectors with JWT authentication.
//!
//! [ArangoDB]: https://www.arangodb.com
//! [JSON]: https://json.org
//! [`rincon_core`]: https://docs.rs/rincon_core
//! [`rincon_client`]: https://docs.rs/rincon_client
//! [`rincon_session`]: https://docs.rs/rincon_session
//! [`tokio_core`]: https://docs.rs/tokio-core
//! [VelocyPack]: https://github.com/arangodb/velocypack
extern crate futures;
extern crate hyper;
extern crate hyper_timeout;
extern crate hyper_tls;
extern crate log;
extern crate native_tls;
extern crate serde;
extern crate serde_json;
extern crate tokio_core;
extern crate url;
extern crate rincon_core;