ruarango/traits/
db.rs

1// Copyright (c) 2021 ruarango developers
2//
3// Licensed under the Apache License, Version 2.0
4// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
5// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. All files in the project carrying such notice may not be copied,
7// modified, or distributed except according to those terms.
8
9//! `ruarango` database trait
10
11use crate::{
12    common::output::Response,
13    db::{input::Create, output::Current},
14    types::ArangoResult,
15};
16use async_trait::async_trait;
17
18/// Database Operations
19#[async_trait]
20pub trait Database {
21    /// Retrieves the properties of the current database
22    async fn current(&self) -> ArangoResult<Response<Current>>;
23    /// Retrieves the list of all databases the current user can access without specifying a different username or password.
24    async fn user(&self) -> ArangoResult<Response<Vec<String>>>;
25    /// Retrieves the list of all existing databases
26    /// *Note*: retrieving the list of databases is only possible from within the _system database.
27    /// *Note*: You should use the `GET user API` to fetch the list of the available databases now.
28    async fn list(&self) -> ArangoResult<Response<Vec<String>>>;
29    /// Creates a new database
30    /// *Note*: creating a new database is only possible from within the _system database.
31    async fn create(&self, db: &Create) -> ArangoResult<Response<bool>>;
32    /// Drops the database along with all data stored in it.
33    /// *Note*: dropping a database is only possible from within the _system database.
34    /// The _system database itself cannot be dropped.
35    async fn drop(&self, name: &str) -> ArangoResult<Response<bool>>;
36}