surrealdb/api/opt/endpoint/
mem.rs1use crate::api::engine::local::Db;
2use crate::api::engine::local::Mem;
3use crate::api::opt::Endpoint;
4use crate::api::opt::IntoEndpoint;
5use crate::api::Result;
6use crate::opt::Config;
7use url::Url;
8
9impl IntoEndpoint<Mem> for () {
10 type Client = Db;
11
12 fn into_endpoint(self) -> Result<Endpoint> {
13 let protocol = "mem://";
14 let url = Url::parse(protocol)
15 .unwrap_or_else(|_| unreachable!("`{protocol}` should be static and valid"));
16 let mut endpoint = Endpoint::new(url);
17 "memory".clone_into(&mut endpoint.path);
18 Ok(endpoint)
19 }
20}
21
22impl IntoEndpoint<Mem> for Config {
23 type Client = Db;
24
25 fn into_endpoint(self) -> Result<Endpoint> {
26 let mut endpoint = IntoEndpoint::<Mem>::into_endpoint(())?;
27 endpoint.config = self;
28 Ok(endpoint)
29 }
30}