diff --git a/waku/src/general/mod.rs b/waku/src/general/mod.rs new file mode 100644 index 0000000..f46e212 --- /dev/null +++ b/waku/src/general/mod.rs @@ -0,0 +1,26 @@ +// std + +// crates +use serde::Deserialize; +// internal + +/// JsonResponse wrapper. +/// `go-waku` ffi returns this type as a `char *` as per the [specification](https://rfc.vac.dev/spec/36/#jsonresponse-type) +/// +#[derive(Deserialize)] +#[serde(rename_all = "snake_case")] +pub(crate) enum JsonResponse { + Result(T), + Error(String), +} + +type Response = Result; + +impl From> for Response { + fn from(response: JsonResponse) -> Self { + match response { + JsonResponse::Result(t) => Ok(t), + JsonResponse::Error(e) => Err(e), + } + } +}