mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-02 14:03:12 +00:00
Added general types
This commit is contained in:
parent
53a8e069af
commit
3132182a7a
@ -3,7 +3,6 @@ use std::env::set_current_dir;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
|
||||
fn main() {
|
||||
// TODO: well, there are a lot of things to consider here, including architechture target. A better aware system should be used.
|
||||
// For now this will have to do
|
||||
@ -20,7 +19,7 @@ fn main() {
|
||||
let output_lib = "libgowaku.a";
|
||||
set_current_dir("./vendor").unwrap();
|
||||
Command::new(go_bin)
|
||||
.env("CGO_ENABLED","1")
|
||||
.env("CGO_ENABLED", "1")
|
||||
.arg("build")
|
||||
.arg("-buildmode=c-archive")
|
||||
.arg("-o")
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
// std
|
||||
|
||||
// crates
|
||||
use serde::{Deserialize, Serialize};
|
||||
// internal
|
||||
@ -33,7 +32,97 @@ impl<T> From<JsonResponse<T>> for Response<T> {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WakuMessage {
|
||||
payload: Box<[u8]>,
|
||||
/// The content topic to be set on the message
|
||||
content_topic: String,
|
||||
/// The Waku Message version number
|
||||
version: usize,
|
||||
/// Unix timestamp in nanoseconds
|
||||
timestamp: usize,
|
||||
}
|
||||
|
||||
/// A payload once decoded, used when a received Waku Message is encrypted
|
||||
pub struct DecodedPayload {
|
||||
/// Public key that signed the message (optional), hex encoded with 0x prefix
|
||||
public_key: Option<String>,
|
||||
/// Message signature (optional), hex encoded with 0x prefix
|
||||
signature: Option<String>,
|
||||
/// Decrypted message payload base64 encoded
|
||||
data: String,
|
||||
/// Padding base64 encoded
|
||||
padding: String,
|
||||
}
|
||||
|
||||
/// The content topic of a Waku message
|
||||
/// as per the [specification](https://rfc.vac.dev/spec/36/#contentfilter-type)
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ContentFilter {
|
||||
/// The content topic of a Waku message
|
||||
content_topic: String,
|
||||
}
|
||||
|
||||
/// The criteria to create subscription to a light node in JSON Format
|
||||
/// as per the [specification](https://rfc.vac.dev/spec/36/#filtersubscription-type)
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FilterSubscription {
|
||||
/// Array of [`ContentFilter`] being subscribed to / unsubscribed from
|
||||
content_filters: Vec<ContentFilter>,
|
||||
/// Optional pubsub topic
|
||||
pubsub_topic: Option<String>,
|
||||
}
|
||||
|
||||
/// Criteria used to retrieve historical messages
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StoreQuery {
|
||||
/// The pubsub topic on which messages are published
|
||||
pubsub_topic: Option<String>,
|
||||
/// Array of [`ContentFilter`] to query for historical messages
|
||||
content_filters: Vec<ContentFilter>,
|
||||
/// The inclusive lower bound on the timestamp of queried messages.
|
||||
/// This field holds the Unix epoch time in nanoseconds
|
||||
start_time: Option<usize>,
|
||||
/// The inclusive upper bound on the timestamp of queried messages.
|
||||
/// This field holds the Unix epoch time in nanoseconds
|
||||
end_time: Option<usize>,
|
||||
/// Paging information in [`PagingOptions`] format
|
||||
paging_options: Option<PagingOptions>,
|
||||
}
|
||||
|
||||
/// The response received after doing a query to a store node
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StoreResponse {
|
||||
/// Array of retrieved historical messages in [`WakuMessage`] format
|
||||
messages: Vec<WakuMessage>,
|
||||
/// Paging information in [`PagingOptions`] format from which to resume further historical queries
|
||||
paging_options: Option<PagingOptions>,
|
||||
}
|
||||
|
||||
/// Paging information
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PagingOptions {
|
||||
/// Number of messages to retrieve per page
|
||||
page_size: usize,
|
||||
/// Message Index from which to perform pagination.
|
||||
/// If not included and forward is set to true, paging will be performed from the beginning of the list.
|
||||
/// If not included and forward is set to false, paging will be performed from the end of the list
|
||||
cursor: Option<MessageIndex>,
|
||||
/// `true` if paging forward, `false` if paging backward
|
||||
forward: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MessageIndex {
|
||||
/// Hash of the message at this [`MessageIndex`]
|
||||
digest: String,
|
||||
/// UNIX timestamp in nanoseconds at which the message at this [`MessageIndex`] was received
|
||||
receiver_time: usize,
|
||||
/// UNIX timestamp in nanoseconds at which the message is generated by its sender
|
||||
sender_time: usize,
|
||||
/// The pubsub topic of the message at this [`MessageIndex`]
|
||||
pubsub_topic: String,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user