migrate to libcwtch-go 1.5 #9

Merged
sarah merged 6 commits from lcg1.5 into main 2022-01-17 23:57:13 +00:00
Owner

I was able to extend the macro_rules! macro to support the new APIs as it turns out!

so all the most uptodate libcwtch-go is here!

also added deserialization error handleing with Result as per #4

I was able to extend the macro_rules! macro to support the new APIs as it turns out! so all the most uptodate libcwtch-go is here! also added deserialization error handleing with Result as per #4
dan added 5 commits 2022-01-16 19:32:51 +00:00
sarah requested changes 2022-01-17 18:38:55 +00:00
Cargo.toml Outdated
@ -14,3 +14,3 @@
serde_json = "1.0"
serde = { version = "1.0.127", features = ["derive"] }
serde_with = { version = "1.10.0" }
serde_with = { version = "1.10.0" }
Owner

what is this needed for?

what is this needed for?
Author
Owner
https://git.openprivacy.ca/cwtch.im/libcwtch-rs/src/branch/main/src/structs.rs#L3 https://git.openprivacy.ca/cwtch.im/libcwtch-rs/src/branch/main/src/structs.rs#L56 https://git.openprivacy.ca/cwtch.im/libcwtch-rs/src/branch/main/src/structs.rs#L65 which i beleive is being used so ConnectionState deserizliaes to default / Disconnected on error / absent
build.rs Outdated
@ -15,3 +14,2 @@
Command::new("wget").arg("https://git.openprivacy.ca/attachments/e77c69f0-9487-4808-bc23-092d943bc4a6").arg("-O").arg(lib_cwtch_path).output().expect("failed to download libCwtch.so");
}
// https://git.openprivacy.ca/cwtch.im/libcwtch-go/releases v1.5.4
Owner

would be really nice to include a hash here to check the received lib against

would be really nice to include a hash here to check the received lib against
dan marked this conversation as resolved
@ -8,2 +8,3 @@
let bot_home = "example_cwtch_dir";
std::fs::remove_dir_all(&bot_home).expect("Error removing previous bot_home directory");
match std::fs::remove_dir_all(&bot_home) {
_ => (),
Owner

handle the error here

handle the error here
Author
Owner

remove_dir_all fails on first run as there's no cwtch bot test dir, so i'm catching and ignoring the error.
is there a more idiomatic way to do this?

remove_dir_all fails on first run as there's no cwtch bot test dir, so i'm catching and ignoring the error. is there a more idiomatic way to do this?
@ -31,3 +31,3 @@
fn drop(&mut self) {
unsafe {
CString::from_raw(self.raw);
drop(CString::from_raw(self.raw));
Owner

I don't think you need an explicit drop here...it should go out of scope automatically?

I don't think you need an explicit drop here...it should go out of scope automatically?
Author
Owner

compiler says otherwise

   Compiling libcwtch v0.1.0 (/home/dan/src/openprivacy/cwtch.im/libcwtch-rs)
warning: unused return value of `CString::from_raw` that must be used
  --> src/bindings_go.rs:33:13
   |
33 |             CString::from_raw(self.raw);
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_must_use)]` on by default
   = note: call `drop(from_raw(ptr))` if you intend to drop the `CString`
compiler says otherwise ``` Compiling libcwtch v0.1.0 (/home/dan/src/openprivacy/cwtch.im/libcwtch-rs) warning: unused return value of `CString::from_raw` that must be used --> src/bindings_go.rs:33:13 | 33 | CString::from_raw(self.raw); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_must_use)]` on by default = note: call `drop(from_raw(ptr))` if you intend to drop the `CString` ```
src/structs.rs Outdated
@ -153,1 +162,3 @@
let servers_map: Vec<Server> = serde_json::from_str(servers_json).unwrap();
let servers_map: Vec<Server> = match serde_json::from_str(servers_json) {
Ok(sm) => sm,
Err(e) => return Err(format!("invalid jason: {:?}", e))
Owner

jason

`jason`
dan marked this conversation as resolved
dan force-pushed lcg1.5 from dfd3d0b992 to 81fbfdd151 2022-01-17 23:39:08 +00:00 Compare
sarah merged commit 433f4d4c83 into main 2022-01-17 23:57:13 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cwtch.im/libcwtch-rs#9
No description provided.