|
@@ -19,6 +19,7 @@ pub enum Message {
|
|
|
EventFromServer(types::SubscriptionId, types::Event),
|
|
|
Request(client::Request),
|
|
|
Notice(String),
|
|
|
+ EndOfStoredEvents(String),
|
|
|
}
|
|
|
|
|
|
impl Message {
|
|
@@ -29,6 +30,13 @@ impl Message {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ pub fn as_end_of_stored_events(&self) -> Option<&str> {
|
|
|
+ match self {
|
|
|
+ Self::EndOfStoredEvents(subscription_id) => Some(subscription_id),
|
|
|
+ _ => None,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
pub fn as_event_from_server(&self) -> Option<(&types::SubscriptionId, &types::Event)> {
|
|
|
match self {
|
|
|
Self::EventFromServer(id, event) => Some((id, event)),
|
|
@@ -77,6 +85,20 @@ impl<'de> de::Deserialize<'de> for Message {
|
|
|
.ok_or_else(|| de::Error::custom("Invalid type for element 0 of the array"))?;
|
|
|
|
|
|
match tag {
|
|
|
+ "EOSE" => {
|
|
|
+ if array.len() != 2 {
|
|
|
+ Err(de::Error::custom("Invalid length for EOSE"))
|
|
|
+ } else {
|
|
|
+ Ok(Self::EndOfStoredEvents(
|
|
|
+ array[1]
|
|
|
+ .as_str()
|
|
|
+ .ok_or_else(|| {
|
|
|
+ de::Error::custom("Invalid subscription_id, expecting string")
|
|
|
+ })?
|
|
|
+ .to_owned(),
|
|
|
+ ))
|
|
|
+ }
|
|
|
+ }
|
|
|
"EVENT" => match array.len() {
|
|
|
3 => {
|
|
|
let subscription_id: SubscriptionId = array[1]
|