surrealdb/api/opt/endpoint/
mem.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
use crate::api::engine::local::Db;
use crate::api::engine::local::Mem;
use crate::api::opt::Endpoint;
use crate::api::opt::IntoEndpoint;
use crate::api::Result;
use crate::opt::Config;
use url::Url;

impl IntoEndpoint<Mem> for () {
	type Client = Db;

	fn into_endpoint(self) -> Result<Endpoint> {
		Ok(Endpoint {
			url: Url::parse("mem://").unwrap(),
			path: "memory".to_owned(),
			config: Default::default(),
		})
	}
}

impl IntoEndpoint<Mem> for Config {
	type Client = Db;

	fn into_endpoint(self) -> Result<Endpoint> {
		let mut endpoint = IntoEndpoint::<Mem>::into_endpoint(())?;
		endpoint.config = self;
		Ok(endpoint)
	}
}