surrealdb/api/opt/endpoint/
indxdb.rs

1use crate::api::engine::local::Db;
2use crate::api::engine::local::IndxDb;
3use crate::api::opt::Config;
4use crate::api::opt::Endpoint;
5use crate::api::opt::IntoEndpoint;
6use crate::api::Result;
7use url::Url;
8
9macro_rules! endpoints {
10	($($name:ty),*) => {
11		$(
12			impl IntoEndpoint<IndxDb> for $name {
13				type Client = Db;
14
15				fn into_endpoint(self) -> Result<Endpoint> {
16					let protocol = "indxdb://";
17					Ok(Endpoint {
18						url: Url::parse(protocol).unwrap(),
19						path: super::path_to_string(protocol, self),
20						config: Default::default(),
21					})
22				}
23			}
24
25			impl IntoEndpoint<IndxDb> for ($name, Config) {
26				type Client = Db;
27
28				fn into_endpoint(self) -> Result<Endpoint> {
29					let mut endpoint = IntoEndpoint::<IndxDb>::into_endpoint(self.0)?;
30					endpoint.config = self.1;
31					Ok(endpoint)
32				}
33			}
34		)*
35	};
36}
37
38endpoints!(&str, &String, String);