mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-05 23:43:11 +00:00
Added topics type aliases
This commit is contained in:
parent
7b7ba2975d
commit
da3596e8f1
@ -3,6 +3,9 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
// internal
|
// internal
|
||||||
|
|
||||||
|
pub type PubsubTopic = String;
|
||||||
|
pub type ContentTopic = String;
|
||||||
|
|
||||||
/// 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.
|
/// This is internal, as it is better to use rust plain `Result` type.
|
||||||
@ -33,7 +36,7 @@ impl<T> From<JsonResponse<T>> for Response<T> {
|
|||||||
pub struct WakuMessage {
|
pub struct WakuMessage {
|
||||||
payload: Box<[u8]>,
|
payload: Box<[u8]>,
|
||||||
/// The content topic to be set on the message
|
/// The content topic to be set on the message
|
||||||
content_topic: String,
|
content_topic: ContentTopic,
|
||||||
/// The Waku Message version number
|
/// The Waku Message version number
|
||||||
version: usize,
|
version: usize,
|
||||||
/// Unix timestamp in nanoseconds
|
/// Unix timestamp in nanoseconds
|
||||||
@ -58,7 +61,7 @@ pub struct DecodedPayload {
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ContentFilter {
|
pub struct ContentFilter {
|
||||||
/// The content topic of a Waku message
|
/// The content topic of a Waku message
|
||||||
content_topic: String,
|
content_topic: ContentTopic,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The criteria to create subscription to a light node in JSON Format
|
/// The criteria to create subscription to a light node in JSON Format
|
||||||
@ -69,7 +72,7 @@ pub struct FilterSubscription {
|
|||||||
/// Array of [`ContentFilter`] being subscribed to / unsubscribed from
|
/// Array of [`ContentFilter`] being subscribed to / unsubscribed from
|
||||||
content_filters: Vec<ContentFilter>,
|
content_filters: Vec<ContentFilter>,
|
||||||
/// Optional pubsub topic
|
/// Optional pubsub topic
|
||||||
pubsub_topic: Option<String>,
|
pubsub_topic: Option<PubsubTopic>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Criteria used to retrieve historical messages
|
/// Criteria used to retrieve historical messages
|
||||||
@ -77,7 +80,7 @@ pub struct FilterSubscription {
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct StoreQuery {
|
pub struct StoreQuery {
|
||||||
/// The pubsub topic on which messages are published
|
/// The pubsub topic on which messages are published
|
||||||
pubsub_topic: Option<String>,
|
pubsub_topic: Option<PubsubTopic>,
|
||||||
/// Array of [`ContentFilter`] to query for historical messages
|
/// Array of [`ContentFilter`] to query for historical messages
|
||||||
content_filters: Vec<ContentFilter>,
|
content_filters: Vec<ContentFilter>,
|
||||||
/// The inclusive lower bound on the timestamp of queried messages.
|
/// The inclusive lower bound on the timestamp of queried messages.
|
||||||
@ -124,5 +127,5 @@ pub struct MessageIndex {
|
|||||||
/// UNIX timestamp in nanoseconds at which the message is generated by its sender
|
/// UNIX timestamp in nanoseconds at which the message is generated by its sender
|
||||||
sender_time: usize,
|
sender_time: usize,
|
||||||
/// The pubsub topic of the message at this [`MessageIndex`]
|
/// The pubsub topic of the message at this [`MessageIndex`]
|
||||||
pubsub_topic: String,
|
pubsub_topic: PubsubTopic,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user