yaml > json
This commit is contained in:
parent
ab08f6e0f3
commit
65bad5849d
35
Cargo.lock
generated
35
Cargo.lock
generated
|
@ -125,7 +125,7 @@ dependencies = [
|
|||
"clap",
|
||||
"matrix-sdk",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"tokio",
|
||||
"tracing-subscriber",
|
||||
"url",
|
||||
|
@ -386,6 +386,12 @@ version = "1.0.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.26"
|
||||
|
@ -805,6 +811,12 @@ version = "0.2.84"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.2"
|
||||
|
@ -1703,6 +1715,18 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.8.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "971be8f6e4d4a47163b405a3df70d14359186f9ab0f3a3ec37df144ca1ce089f"
|
||||
dependencies = [
|
||||
"dtoa",
|
||||
"linked-hash-map",
|
||||
"serde",
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.6.0"
|
||||
|
@ -2384,6 +2408,15 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
|
||||
dependencies = [
|
||||
"linked-hash-map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.2.0"
|
||||
|
|
|
@ -11,7 +11,7 @@ clap = "3.0.0-beta.2"
|
|||
tokio = { version = "1", features = [ "full" ] }
|
||||
tracing-subscriber = "0.2"
|
||||
url = { version = "2.2", features = [ "serde" ] }
|
||||
serde_json = "1"
|
||||
serde_yaml = "0.8"
|
||||
serde = "1.0"
|
||||
|
||||
[dependencies.matrix-sdk]
|
||||
|
|
|
@ -105,7 +105,7 @@ async fn load_or_init_session(
|
|||
if session_file.is_file() {
|
||||
let reader = BufReader::new(File::open(session_file).unwrap());
|
||||
|
||||
let session: Session = serde_json::from_reader(reader).unwrap();
|
||||
let session: Session = serde_yaml::from_reader(reader).unwrap();
|
||||
|
||||
client.restore_login(session.clone()).await.unwrap();
|
||||
|
||||
|
@ -125,7 +125,7 @@ async fn load_or_init_session(
|
|||
};
|
||||
|
||||
let writer = BufWriter::new(File::create(session_file).unwrap());
|
||||
serde_json::to_writer(writer, &session).unwrap();
|
||||
serde_yaml::to_writer(writer, &session).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ async fn login_and_sync(
|
|||
|
||||
let client = Client::new_with_config(homeserver_url, client_config).unwrap();
|
||||
|
||||
load_or_init_session(&client, state_dir.join("session.json"), username, password).await;
|
||||
load_or_init_session(&client, state_dir.join("session.yaml"), username, password).await;
|
||||
|
||||
client
|
||||
.add_event_emitter(Box::new(AutoJoinBot::new(client.clone())))
|
||||
|
@ -175,7 +175,7 @@ async fn main() -> Result<(), matrix_sdk::Error> {
|
|||
let config_file = opts.config;
|
||||
|
||||
let config: Config =
|
||||
serde_json::from_reader(BufReader::new(File::open(config_file).unwrap())).unwrap();
|
||||
serde_yaml::from_reader(BufReader::new(File::open(config_file).unwrap())).unwrap();
|
||||
|
||||
login_and_sync(
|
||||
config.homeserver,
|
||||
|
|
Loading…
Reference in a new issue