diff --git a/waku-sys/build.rs b/waku-sys/build.rs index b0ac775..4cacae8 100644 --- a/waku-sys/build.rs +++ b/waku-sys/build.rs @@ -1,4 +1,3 @@ -use bindgen; use std::env; use std::env::set_current_dir; use std::path::PathBuf; diff --git a/waku/src/general/mod.rs b/waku/src/general/mod.rs index f46e212..86ba620 100644 --- a/waku/src/general/mod.rs +++ b/waku/src/general/mod.rs @@ -1,12 +1,12 @@ // std // crates -use serde::Deserialize; +use serde::{Deserialize, Serialize}; // internal /// JsonResponse wrapper. /// `go-waku` ffi returns this type as a `char *` as per the [specification](https://rfc.vac.dev/spec/36/#jsonresponse-type) -/// +/// This is internal, as it is better to use rust plain `Result` type. #[derive(Deserialize)] #[serde(rename_all = "snake_case")] pub(crate) enum JsonResponse { @@ -14,6 +14,8 @@ pub(crate) enum JsonResponse { Error(String), } +/// Waku response, just a `Result` with an `String` error. +/// Convenient we can transform a [`JsonResponse`] into a [`Response`] (`Result`) type Response = Result; impl From> for Response { @@ -24,3 +26,14 @@ impl From> for Response { } } } + +/// JsonMessage, Waku message in JSON format. +/// as per the [specification](https://rfc.vac.dev/spec/36/#jsonmessage-type) +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct WakuMessage { + payload: Box<[u8]>, + content_topic: String, + version: usize, + timestamp: usize, +}