mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-02 14:03:12 +00:00
Added wakumessage
This commit is contained in:
parent
e76361d5fc
commit
6db57b44b6
@ -1,4 +1,3 @@
|
||||
use bindgen;
|
||||
use std::env;
|
||||
use std::env::set_current_dir;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@ -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<T> {
|
||||
@ -14,6 +14,8 @@ pub(crate) enum JsonResponse<T> {
|
||||
Error(String),
|
||||
}
|
||||
|
||||
/// Waku response, just a `Result` with an `String` error.
|
||||
/// Convenient we can transform a [`JsonResponse`] into a [`Response`] (`Result`)
|
||||
type Response<T> = Result<T, String>;
|
||||
|
||||
impl<T> From<JsonResponse<T>> for Response<T> {
|
||||
@ -24,3 +26,14 @@ impl<T> From<JsonResponse<T>> for Response<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user