ad4m_client/
lib.rs

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
use std::sync::Arc;

use agent::AgentClient;
use expressions::ExpressionsClient;
use languages::LanguagesClient;
use neighbourhoods::NeighbourhoodsClient;
use perspectives::PerspectivesClient;
use runtime::RuntimeClient;

extern crate anyhow;
extern crate async_tungstenite;
extern crate chrono;
extern crate clap;
extern crate dirs;
extern crate graphql_client;
extern crate maplit;
extern crate rand;
extern crate regex;
extern crate reqwest;
extern crate rustyline;
extern crate tokio;

pub mod agent;
pub mod expressions;
pub mod languages;
pub mod literal;
pub mod neighbourhoods;
pub mod perspective_proxy;
pub mod perspectives;
pub mod runtime;
pub mod subject_proxy;
pub mod types;
mod util;

pub struct Ad4mClient {
    pub agent: AgentClient,
    pub languages: LanguagesClient,
    pub neighbourhoods: NeighbourhoodsClient,
    pub perspectives: PerspectivesClient,
    pub expressions: ExpressionsClient,
    pub runtime: RuntimeClient,
}

pub struct ClientInfo {
    pub executor_url: String,
    pub cap_token: String,
}

impl Ad4mClient {
    pub fn new(executor_url: String, cap_token: String) -> Self {
        let info = Arc::new(ClientInfo {
            executor_url,
            cap_token,
        });

        Self {
            agent: AgentClient::new(info.clone()),
            languages: LanguagesClient::new(info.clone()),
            neighbourhoods: NeighbourhoodsClient::new(info.clone()),
            perspectives: PerspectivesClient::new(info.clone()),
            expressions: ExpressionsClient::new(info.clone()),
            runtime: RuntimeClient::new(info),
        }
    }
}