Struct arangors::connection::GenericConnection [−][src]
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]
impl<S, C: ClientExt> GenericConnection<C, S>
[src]pub async fn validate_server(arango_url: &str) -> Result<(), ClientError>
[src]
Validate the server at given arango url
Cast ClientError
if
- Invalid url
- Connection failed
- SERVER header in response header is not
ArangoDB
or empty
pub fn url(&self) -> &Url
[src]
Get url for remote arangoDB server.
pub fn 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]
pub async fn accessible_databases(
&self
) -> Result<HashMap<String, Permission>, ClientError>
[src]
&self
) -> Result<HashMap<String, Permission>, ClientError>
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.
pub async fn server_role(&self) -> Result<String, ClientError>
[src]
Possible return values for role are: SINGLE: the server is a standalone server without clustering COORDINATOR: the server is a Coordinator in a cluster PRIMARY: the server is a DB-Server in a cluster SECONDARY: this role is not used anymore AGENT: the server is an Agency node in a cluster UNDEFINED: in a cluster, UNDEFINED is returned if the server role cannot be determined.
Note
this function would make a request to arango server.
impl<C: ClientExt> GenericConnection<C, Normal>
[src]
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]
arango_url: T
) -> Result<GenericConnection<C, Normal>, ClientError>
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:
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]
arango_url: &str,
username: &str,
password: &str
) -> Result<GenericConnection<C, Normal>, ClientError>
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]
arango_url: &str,
username: &str,
password: &str
) -> Result<GenericConnection<C, Normal>, ClientError>
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]
&self,
name: &str
) -> Result<Database<C>, ClientError>
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]
pub async fn into_admin(
self
) -> Result<GenericConnection<C, Admin>, ClientError>
[src]
self
) -> Result<GenericConnection<C, Admin>, ClientError>
impl<C: ClientExt> GenericConnection<C, Admin>
[src]
impl<C: ClientExt> GenericConnection<C, Admin>
[src]pub fn into_normal(self) -> GenericConnection<C, Normal>
[src]
Trait Implementations
impl<C: Clone + ClientExt, S: Clone> Clone for GenericConnection<C, S>
[src]
impl<C: Clone + ClientExt, S: Clone> Clone for GenericConnection<C, S>
[src]fn clone(&self) -> GenericConnection<C, S>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<C: ClientExt> From<GenericConnection<C, Admin>> for GenericConnection<C, Normal>
[src]
impl<C: ClientExt> From<GenericConnection<C, Admin>> for GenericConnection<C, Normal>
[src]fn from(conn: GenericConnection<C, Admin>) -> GenericConnection<C, Normal>
[src]
impl<C: ClientExt> From<GenericConnection<C, Normal>> for GenericConnection<C, Admin>
[src]
impl<C: ClientExt> From<GenericConnection<C, Normal>> for GenericConnection<C, Admin>
[src]fn from(conn: GenericConnection<C, Normal>) -> GenericConnection<C, Admin>
[src]
Auto Trait Implementations
impl<C, S> RefUnwindSafe for GenericConnection<C, S> where
C: RefUnwindSafe,
S: RefUnwindSafe,
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> 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> Sync for GenericConnection<C, S> where
C: Send,
S: Sync,
impl<C, S> Unpin for GenericConnection<C, S> where
S: Unpin,
impl<C, S> Unpin for GenericConnection<C, S> where
S: Unpin,
impl<C, S> UnwindSafe for GenericConnection<C, S> where
C: RefUnwindSafe,
S: UnwindSafe,
impl<C, S> UnwindSafe for GenericConnection<C, S> where
C: RefUnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]