surrealdb/api/opt/
export.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
use std::path::Path;
use std::path::PathBuf;

#[derive(Debug)]
#[non_exhaustive]
pub enum ExportDestination {
	File(PathBuf),
	Memory,
}

/// A trait for converting inputs into database export locations
pub trait IntoExportDestination<R> {
	/// Converts an input into a database export location
	fn into_export_destination(self) -> ExportDestination;
}

impl<T> IntoExportDestination<PathBuf> for T
where
	T: AsRef<Path>,
{
	fn into_export_destination(self) -> ExportDestination {
		ExportDestination::File(self.as_ref().to_path_buf())
	}
}

impl IntoExportDestination<()> for () {
	fn into_export_destination(self) -> ExportDestination {
		ExportDestination::Memory
	}
}