surrealdb/api/opt/
export.rs

1use std::path::Path;
2use std::path::PathBuf;
3
4#[derive(Debug)]
5#[non_exhaustive]
6pub enum ExportDestination {
7	File(PathBuf),
8	Memory,
9}
10
11/// A trait for converting inputs into database export locations
12pub trait IntoExportDestination<R> {
13	/// Converts an input into a database export location
14	fn into_export_destination(self) -> ExportDestination;
15}
16
17impl<T> IntoExportDestination<PathBuf> for T
18where
19	T: AsRef<Path>,
20{
21	fn into_export_destination(self) -> ExportDestination {
22		ExportDestination::File(self.as_ref().to_path_buf())
23	}
24}
25
26impl IntoExportDestination<()> for () {
27	fn into_export_destination(self) -> ExportDestination {
28		ExportDestination::Memory
29	}
30}