Refactor waku crate to waku-bindings

This commit is contained in:
Daniel Sanchez Quiros 2022-11-29 10:28:32 +01:00
parent 533619670f
commit 718c28725d
6 changed files with 12 additions and 10 deletions

4
Cargo.lock generated
View File

@ -1098,7 +1098,7 @@ dependencies = [
"prost",
"tui",
"unicode-width",
"waku",
"waku-bindings",
]
[[package]]
@ -1193,7 +1193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "waku"
name = "waku-bindings"
version = "0.1.0-beta1"
dependencies = [
"aes-gcm",

View File

@ -8,7 +8,7 @@ authors = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
waku = { path = "../../waku-bindings" }
waku-bindings = { path = "../../waku-bindings" }
tui = "0.19"
crossterm = "0.25"
unicode-width = "0.1"

View File

@ -22,7 +22,7 @@ use tui::{
Frame, Terminal,
};
use unicode_width::UnicodeWidthStr;
use waku::{
use waku_bindings::{
waku_new, waku_set_event_callback, ContentFilter, Multiaddr, PagingOptions, ProtocolId,
Running, StoreQuery, WakuMessage, WakuNodeHandle,
};
@ -62,7 +62,9 @@ impl App {
}
}
}
fn retrieve_history(node_handle: &WakuNodeHandle<Running>) -> waku::Result<Vec<Chat2Message>> {
fn retrieve_history(
node_handle: &WakuNodeHandle<Running>,
) -> waku_bindings::Result<Vec<Chat2Message>> {
let self_id = node_handle.peer_id().unwrap();
let peer = node_handle
.peers()?
@ -130,7 +132,7 @@ fn main() -> std::result::Result<(), Box<dyn Error>> {
}
let shared_messages = Arc::clone(&app.messages);
waku_set_event_callback(move |signal| match signal.event() {
waku::Event::WakuMessage(event) => {
waku_bindings::Event::WakuMessage(event) => {
match <Chat2Message as Message>::decode(event.waku_message().payload()) {
Ok(chat_message) => {
shared_messages.write().unwrap().push(chat_message);
@ -141,7 +143,7 @@ fn main() -> std::result::Result<(), Box<dyn Error>> {
}
}
}
waku::Event::Unrecognized(data) => {
waku_bindings::Event::Unrecognized(data) => {
let mut out = std::io::stderr();
write!(out, "Error, received unrecognized event {data}").unwrap();
}

View File

@ -1,7 +1,7 @@
use chrono::{DateTime, TimeZone, Utc};
use once_cell::sync::Lazy;
use prost::Message;
use waku::{Encoding, WakuContentTopic};
use waku_bindings::{Encoding, WakuContentTopic};
pub static TOY_CHAT_CONTENT_TOPIC: Lazy<WakuContentTopic> = Lazy::new(|| WakuContentTopic {
application_name: "toy-chat".into(),

View File

@ -1,5 +1,5 @@
[package]
name = "waku"
name = "waku-bindings"
version = "0.1.0-beta1"
edition = "2021"
authors = [

View File

@ -5,7 +5,7 @@ use secp256k1::{PublicKey, Secp256k1, SecretKey};
use std::net::IpAddr;
use std::str::FromStr;
use std::time::{Duration, SystemTime};
use waku::{
use waku_bindings::{
waku_new, waku_set_event_callback, Encoding, Event, ProtocolId, WakuContentTopic, WakuLogLevel,
WakuMessage, WakuNodeConfig,
};