mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-11 10:23:06 +00:00
* Wrapped lightpush * Optional signing key on relay a/symmetric publish * Added lightpush docs * Implemented filter methods wrappers * Implemented store methods wrappers * WakuHandle docs * Plumbing filter, lightpush and store into node * Callback RwLock -> Mutex * Removed wrong todo * Docs modules titles and links * Missing link * Implemented message decoding * Decrypt docs header * Added message and payload todos * Added missing structs fields exposures and constructors * Payload as base64 * Deserialize base64 encoded strings Use proper types on payload * Added MessageIndex type doc header * Added missing documentation * Added main lib header doc
43 lines
1.8 KiB
Rust
43 lines
1.8 KiB
Rust
//! Waku [store](https://rfc.vac.dev/spec/36/#waku-store) handling methods
|
|
|
|
// std
|
|
use std::ffi::{CStr, CString};
|
|
use std::time::Duration;
|
|
// crates
|
|
// internal
|
|
use crate::general::{JsonResponse, PeerId, Result, StoreQuery, StoreResponse};
|
|
|
|
/// Retrieves historical messages on specific content topics. This method may be called with [`PagingOptions`](`crate::general::PagingOptions`),
|
|
/// to retrieve historical messages on a per-page basis. If the request included [`PagingOptions`](`crate::general::PagingOptions`),
|
|
/// the node must return messages on a per-page basis and include [`PagingOptions`](`crate::general::PagingOptions`) in the response.
|
|
/// These [`PagingOptions`](`crate::general::PagingOptions`) must contain a cursor pointing to the Index from which a new page can be requested
|
|
pub fn waku_store_query(
|
|
query: &StoreQuery,
|
|
peer_id: PeerId,
|
|
timeout: Duration,
|
|
) -> Result<StoreResponse> {
|
|
let result = unsafe {
|
|
CStr::from_ptr(waku_sys::waku_store_query(
|
|
CString::new(
|
|
serde_json::to_string(query)
|
|
.expect("StoreQuery should always be able to be serialized"),
|
|
)
|
|
.expect("CString should build properly from the serialized filter subscription")
|
|
.into_raw(),
|
|
CString::new(peer_id)
|
|
.expect("CString should build properly from peer id")
|
|
.into_raw(),
|
|
timeout
|
|
.as_millis()
|
|
.try_into()
|
|
.expect("Duration as milliseconds should fit in a i32"),
|
|
))
|
|
}
|
|
.to_str()
|
|
.expect("Response should always succeed to load to a &str");
|
|
|
|
let response: JsonResponse<StoreResponse> =
|
|
serde_json::from_str(result).expect("JsonResponse should always succeed to deserialize");
|
|
response.into()
|
|
}
|