Update toml
This commit is contained in:
parent
a2abc146f4
commit
21ffc4111e
603
Cargo.lock
generated
603
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -18,6 +18,6 @@ reqwest = { version = "0.11", default-features = false, features = [
|
||||||
] }
|
] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
toml = "0.5"
|
toml = "0.8"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
url = { version = "2.0", features = ["serde"] }
|
url = { version = "2.0", features = ["serde"] }
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -94,27 +94,27 @@ impl Mastodon {
|
||||||
|
|
||||||
async fn read_token(path: impl AsRef<Path>) -> Result<Token> {
|
async fn read_token(path: impl AsRef<Path>) -> Result<Token> {
|
||||||
let mut file = File::open(path).await?;
|
let mut file = File::open(path).await?;
|
||||||
let mut contents = vec![];
|
let mut contents = String::new();
|
||||||
file.read_to_end(&mut contents).await?;
|
file.read_to_string(&mut contents).await?;
|
||||||
|
|
||||||
let token: Token = toml::from_slice(&contents)?;
|
let token: Token = toml::from_str(&contents)?;
|
||||||
Ok(token)
|
Ok(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn write_token(path: impl AsRef<Path>, token: &Token) -> Result<()> {
|
async fn write_token(path: impl AsRef<Path>, token: &Token) -> Result<()> {
|
||||||
let token_bytes = toml::to_vec(token)?;
|
let token_bytes = toml::to_string(token)?;
|
||||||
let mut file = File::create(path).await?;
|
let mut file = File::create(path).await?;
|
||||||
file.write_all(&token_bytes).await?;
|
file.write_all(token_bytes.as_bytes()).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
async fn open(path: impl AsRef<Path>) -> Result<Self> {
|
async fn open(path: impl AsRef<Path>) -> Result<Self> {
|
||||||
let mut file = File::open(path).await?;
|
let mut file = File::open(path).await?;
|
||||||
let mut contents = vec![];
|
let mut contents = String::new();
|
||||||
file.read_to_end(&mut contents).await?;
|
file.read_to_string(&mut contents).await?;
|
||||||
|
|
||||||
let config: Config = toml::from_slice(&contents)?;
|
let config: Config = toml::from_str(&contents)?;
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue