Skip to content

Commit

Permalink
move to anyhow
Browse files Browse the repository at this point in the history
  • Loading branch information
timglabisch committed Jul 5, 2023
1 parent 6bf878e commit a4b6727
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 24 deletions.
101 changes: 80 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions mehsh_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["timglabisch <[email protected]>"]
edition = "2018"

[dependencies]
toml = "0.5"
toml = "0.*"
anyhow = "*"
serde = { version = "1.0", features = ["derive"] }
bytes = "0.5.3"
bytes = "1.4.0"
rand = "*"
5 changes: 4 additions & 1 deletion mehsh_common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use anyhow::Context;

mod allow_addr;

Expand Down Expand Up @@ -156,7 +157,9 @@ impl Config {
self_server_identifier: ServerIdentifier,
content: &[u8],
) -> Result<Self, ::anyhow::Error> {
let raw_config = toml::from_slice::<RawConfig>(content)?;
let raw_config = toml::from_str::<RawConfig>(
String::from_utf8(content.to_vec()).context("could not read toml, invalid utf8")?.as_str()
)?;

let servers = raw_config
.server
Expand Down

0 comments on commit a4b6727

Please sign in to comment.