2024-01-09 15:27:03 +00:00
|
|
|
#![allow(unused_imports)]
|
2023-07-19 14:35:56 +00:00
|
|
|
#![allow(dead_code)]
|
2023-08-04 17:43:23 +00:00
|
|
|
|
2024-03-01 08:29:42 +00:00
|
|
|
pub mod docker;
|
2023-08-04 17:43:23 +00:00
|
|
|
pub mod error;
|
2024-03-01 08:29:42 +00:00
|
|
|
pub mod expected;
|
2024-01-09 15:27:03 +00:00
|
|
|
pub mod format;
|
2024-03-01 08:29:42 +00:00
|
|
|
pub mod rest_client;
|
2024-01-09 15:27:03 +00:00
|
|
|
pub mod server;
|
|
|
|
pub mod socket;
|
2023-08-04 17:43:23 +00:00
|
|
|
|
2024-01-09 15:27:03 +00:00
|
|
|
pub use format::*;
|
|
|
|
pub use server::*;
|
|
|
|
pub use socket::*;
|
2023-08-18 13:16:02 +00:00
|
|
|
|
|
|
|
/// Check if the given message is a successful notification from LQ.
|
2024-01-09 15:27:03 +00:00
|
|
|
pub fn is_notification(msg: &serde_json::Value) -> bool {
|
2023-08-18 13:16:02 +00:00
|
|
|
// Example of LQ notification:
|
|
|
|
//
|
|
|
|
// Object {"result": Object {"action": String("CREATE"), "id": String("04460f07-b0e1-4339-92db-049a94aeec10"), "result": Object {"id": String("table_FD40A9A361884C56B5908A934164884A:⟨an-id-goes-here⟩"), "name": String("ok")}}}
|
|
|
|
msg.is_object()
|
|
|
|
&& msg["result"].is_object()
|
|
|
|
&& msg["result"]
|
|
|
|
.as_object()
|
|
|
|
.unwrap()
|
|
|
|
.keys()
|
2024-09-15 23:48:57 +00:00
|
|
|
.all(|k| ["id", "action", "record", "result"].contains(&k.as_str()))
|
2023-08-18 13:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Check if the given message is a notification from LQ and comes from the given LQ ID.
|
2024-01-09 15:27:03 +00:00
|
|
|
pub fn is_notification_from_lq(msg: &serde_json::Value, id: &str) -> bool {
|
|
|
|
is_notification(msg)
|
2023-08-18 13:16:02 +00:00
|
|
|
&& msg["result"].as_object().unwrap().get("id").unwrap().as_str() == Some(id)
|
|
|
|
}
|