mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-02 14:03:12 +00:00
fix: content topic should accept strings
This commit is contained in:
parent
dc32f22f4a
commit
e4672df292
@ -3,7 +3,7 @@ use prost::Message;
|
||||
use waku_bindings::{Encoding, WakuContentTopic};
|
||||
|
||||
pub static TOY_CHAT_CONTENT_TOPIC: WakuContentTopic =
|
||||
WakuContentTopic::new("toy-chat", 2, "huilong", Encoding::Proto);
|
||||
WakuContentTopic::new("toy-chat", "2", "huilong", Encoding::Proto);
|
||||
|
||||
#[derive(Clone, Message)]
|
||||
pub struct Chat2Message {
|
||||
|
||||
@ -442,7 +442,7 @@ impl RegexRepresentation for Encoding {
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct WakuContentTopic {
|
||||
pub application_name: Cow<'static, str>,
|
||||
pub version: usize,
|
||||
pub version: Cow<'static, str>,
|
||||
pub content_topic_name: Cow<'static, str>,
|
||||
pub encoding: Encoding,
|
||||
}
|
||||
@ -450,13 +450,13 @@ pub struct WakuContentTopic {
|
||||
impl WakuContentTopic {
|
||||
pub const fn new(
|
||||
application_name: &'static str,
|
||||
version: usize,
|
||||
version: &'static str,
|
||||
content_topic_name: &'static str,
|
||||
encoding: Encoding,
|
||||
) -> Self {
|
||||
Self {
|
||||
application_name: Cow::Borrowed(application_name),
|
||||
version,
|
||||
version: Cow::Borrowed(version),
|
||||
content_topic_name: Cow::Borrowed(content_topic_name),
|
||||
encoding,
|
||||
}
|
||||
@ -468,11 +468,11 @@ impl FromStr for WakuContentTopic {
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
if let Ok((application_name, version, content_topic_name, encoding)) =
|
||||
scanf!(s, "/{}/{}/{}/{:/.+?/}", String, usize, String, Encoding)
|
||||
scanf!(s, "/{}/{}/{}/{:/.+?/}", String, String, String, Encoding)
|
||||
{
|
||||
Ok(WakuContentTopic {
|
||||
application_name: Cow::Owned(application_name),
|
||||
version,
|
||||
version: Cow::Owned(version),
|
||||
content_topic_name: Cow::Owned(content_topic_name),
|
||||
encoding,
|
||||
})
|
||||
@ -600,7 +600,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn encode_decode() {
|
||||
let content_topic = WakuContentTopic::new("hello", 2, "world", Encoding::Proto);
|
||||
let content_topic = WakuContentTopic::new("hello", "2", "world", Encoding::Proto);
|
||||
let message = WakuMessage::new(
|
||||
"hello",
|
||||
content_topic,
|
||||
|
||||
@ -159,7 +159,7 @@ async fn discv5_echo() -> Result<(), String> {
|
||||
// Subscribe to default channel.
|
||||
let content_filter = ContentFilter::new(Some(waku_default_pubsub_topic()), vec![]);
|
||||
node.relay_subscribe(&content_filter)?;
|
||||
let content_topic = WakuContentTopic::new("toychat", 2, "huilong", Encoding::Proto);
|
||||
let content_topic = WakuContentTopic::new("toychat", "2", "huilong", Encoding::Proto);
|
||||
|
||||
let topics = node.relay_topics()?;
|
||||
let default_topic = waku_default_pubsub_topic();
|
||||
@ -218,7 +218,7 @@ async fn default_echo() -> Result<(), String> {
|
||||
// subscribe to default channel
|
||||
let content_filter = ContentFilter::new(Some(waku_default_pubsub_topic()), vec![]);
|
||||
node.relay_subscribe(&content_filter)?;
|
||||
let content_topic = WakuContentTopic::new("toychat", 2, "huilong", Encoding::Proto);
|
||||
let content_topic = WakuContentTopic::new("toychat", "2", "huilong", Encoding::Proto);
|
||||
|
||||
let sleep = time::sleep(Duration::from_secs(ECHO_TIMEOUT));
|
||||
tokio::pin!(sleep);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user