1use std::path::PathBuf;
2
3use anyhow::Result;
4use tokio::io::AsyncWriteExt;
5
6pub async fn read_from_file(path: PathBuf) -> Result<String> {
7 Ok(tokio::fs::read_to_string(&path).await?)
8}
9
10pub async fn write_to_file(path: PathBuf, content: &str) -> Result<()> {
11 Ok(tokio::fs::write(&path, content.as_bytes()).await?)
12}
13
14pub async fn append_to_file(path: PathBuf, content: &str) -> Result<()> {
15 tokio::fs::OpenOptions::new()
16 .append(true)
17 .open(&path)
18 .await?
19 .write_all(content.as_bytes())
20 .await?;
21 Ok(())
22}