pub trait SaveToFile {
type Error;
// Required method
fn save_to_file<'life0, 'async_trait>(
&'life0 self,
filename: impl AsRef<Path> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}
Required Associated Types§
Required Methods§
fn save_to_file<'life0, 'async_trait>(
&'life0 self,
filename: impl AsRef<Path> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl SaveToFile for String
impl SaveToFile for String
Source§impl<K, V> SaveToFile for HashMap<K, V>where
K: Serialize + DeserializeOwned + Eq + Hash + Send + Sync + 'static,
V: Serialize + DeserializeOwned + Send + Sync + 'static,
A specialized SaveToFile/LoadFromFile impl for HashMap<K, V>,
so you can avoid the universal blanket approach and thus not conflict with
your macro-based impl_default_save_to_file_traits!
expansions.
impl<K, V> SaveToFile for HashMap<K, V>where
K: Serialize + DeserializeOwned + Eq + Hash + Send + Sync + 'static,
V: Serialize + DeserializeOwned + Send + Sync + 'static,
A specialized SaveToFile/LoadFromFile impl for HashMap<K, V>,
so you can avoid the universal blanket approach and thus not conflict with
your macro-based impl_default_save_to_file_traits!
expansions.
This requires that K,V: Serialize + DeserializeOwned. Also note that we require K: Eq + Hash. Then you can do:
let map: HashMap<String, MyStruct> = …; map.save_to_file(“some.json”).await?;
type Error = SaveLoadError
fn save_to_file<'life0, 'async_trait>(
&'life0 self,
filename: impl AsRef<Path> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), <HashMap<K, V> as SaveToFile>::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
HashMap<K, V>: 'async_trait,
Source§impl<T> SaveToFile for Vec<T>
Implements SaveToFile for Vec<T>
, writing its contents as JSON array,
where T: Serialize + DeserializeOwned + Send + Sync + 'static
.
impl<T> SaveToFile for Vec<T>
Implements SaveToFile for Vec<T>
, writing its contents as JSON array,
where T: Serialize + DeserializeOwned + Send + Sync + 'static
.