mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-08 17:03:08 +00:00
Added content topic, update pubsub topic
This commit is contained in:
parent
8533517bcd
commit
0621e87370
@ -170,21 +170,21 @@ impl RegexRepresentation for Encoding {
|
|||||||
const REGEX: &'static str = r"\w";
|
const REGEX: &'static str = r"\w";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WakuPubsubTopic {
|
pub struct WakuContentTopic {
|
||||||
application_name: String,
|
application_name: String,
|
||||||
version: usize,
|
version: usize,
|
||||||
content_topic_name: String,
|
content_topic_name: String,
|
||||||
encoding: Encoding,
|
encoding: Encoding,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for WakuPubsubTopic {
|
impl FromStr for WakuContentTopic {
|
||||||
type Err = String;
|
type Err = String;
|
||||||
|
|
||||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
if let Ok((application_name, version, content_topic_name, encoding)) =
|
if let Ok((application_name, version, content_topic_name, encoding)) =
|
||||||
scanf!(s, "{}/{}/{}/{}", String, usize, String, Encoding)
|
scanf!(s, "/{}/{}/{}/{}", String, usize, String, Encoding)
|
||||||
{
|
{
|
||||||
Ok(WakuPubsubTopic {
|
Ok(WakuContentTopic {
|
||||||
application_name,
|
application_name,
|
||||||
version,
|
version,
|
||||||
content_topic_name,
|
content_topic_name,
|
||||||
@ -200,3 +200,28 @@ impl FromStr for WakuPubsubTopic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct WakuPubSubTopic {
|
||||||
|
topic_name: String,
|
||||||
|
encoding: Encoding,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromStr for WakuPubSubTopic {
|
||||||
|
type Err = String;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
|
if let Ok((topic_name, encoding)) = scanf!(s, "/waku/v2/{}/{}", String, Encoding) {
|
||||||
|
Ok(WakuPubSubTopic {
|
||||||
|
topic_name,
|
||||||
|
encoding,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(
|
||||||
|
format!(
|
||||||
|
"Wrong pub-sub topic format. Should be `/{{application-name}}/{{version-of-the-application}}/{{content-topic-name}}/{{encoding}}`. Got: {}",
|
||||||
|
s
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user