mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-07 16:33:08 +00:00
Added wakumessage
This commit is contained in:
parent
28802ca4a1
commit
35e1393843
@ -1,12 +1,12 @@
|
|||||||
// std
|
// std
|
||||||
|
|
||||||
// crates
|
// crates
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
// internal
|
// internal
|
||||||
|
|
||||||
/// JsonResponse wrapper.
|
/// JsonResponse wrapper.
|
||||||
/// `go-waku` ffi returns this type as a `char *` as per the [specification](https://rfc.vac.dev/spec/36/#jsonresponse-type)
|
/// `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)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub(crate) enum JsonResponse<T> {
|
pub(crate) enum JsonResponse<T> {
|
||||||
@ -14,6 +14,8 @@ pub(crate) enum JsonResponse<T> {
|
|||||||
Error(String),
|
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>;
|
type Response<T> = Result<T, String>;
|
||||||
|
|
||||||
impl<T> From<JsonResponse<T>> for Response<T> {
|
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