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
31
32
use std::fs::File;
use std::io;
use std::path::Path;
#[cfg(feature = "tora_derive")]
pub use tora_derive::*;
use crate::read::{FromReader, ToraRead};
use crate::write::{SerializeIo, ToraWrite};
pub mod read;
pub mod write;
pub fn write_to_file<P, C>(path: P, content: &C) -> io::Result<()>
where
P: AsRef<Path>,
C: SerializeIo,
{
let mut file = File::create(path)?;
file.writes(content)
}
pub fn read_from_file<T, P>(path: P) -> io::Result<T>
where
P: AsRef<Path>,
T: FromReader,
{
let mut file = File::open(path)?;
file.reads()
}