pub enum StreamMessage {
Subscribe {
id: String,
source: String,
transform: Option<String>,
interval_ms: Option<u64>,
},
Unsubscribe {
id: String,
},
Data {
id: String,
payload: Value,
seq: u64,
timestamp: Option<u64>,
},
Error {
id: Option<String>,
message: String,
code: Option<i32>,
},
Ack {
id: String,
status: Option<String>,
},
Ping {
timestamp: u64,
},
Pong {
timestamp: u64,
},
}Expand description
Stream message types for the protocol.
Variants§
Subscribe
Subscribe to a data source
Fields
Unsubscribe
Unsubscribe from a data source
Data
Data update from server
Fields
Error
Error message
Fields
Ack
Acknowledgment
Ping
Heartbeat/ping
Pong
Heartbeat response
Implementations§
Source§impl StreamMessage
impl StreamMessage
Sourcepub fn subscribe(
id: impl Into<String>,
source: impl Into<String>,
) -> StreamMessage
pub fn subscribe( id: impl Into<String>, source: impl Into<String>, ) -> StreamMessage
Create a subscribe message.
Sourcepub fn subscribe_with_transform(
id: impl Into<String>,
source: impl Into<String>,
transform: impl Into<String>,
) -> StreamMessage
pub fn subscribe_with_transform( id: impl Into<String>, source: impl Into<String>, transform: impl Into<String>, ) -> StreamMessage
Create a subscribe message with transform.
Sourcepub fn unsubscribe(id: impl Into<String>) -> StreamMessage
pub fn unsubscribe(id: impl Into<String>) -> StreamMessage
Create an unsubscribe message.
Sourcepub fn data(id: impl Into<String>, payload: Value, seq: u64) -> StreamMessage
pub fn data(id: impl Into<String>, payload: Value, seq: u64) -> StreamMessage
Create a data message.
Sourcepub fn error(message: impl Into<String>) -> StreamMessage
pub fn error(message: impl Into<String>) -> StreamMessage
Create an error message.
Sourcepub fn error_for(
id: impl Into<String>,
message: impl Into<String>,
) -> StreamMessage
pub fn error_for( id: impl Into<String>, message: impl Into<String>, ) -> StreamMessage
Create an error message for a subscription.
Sourcepub fn ack(id: impl Into<String>) -> StreamMessage
pub fn ack(id: impl Into<String>) -> StreamMessage
Create an ack message.
Sourcepub fn ping(timestamp: u64) -> StreamMessage
pub fn ping(timestamp: u64) -> StreamMessage
Create a ping message.
Sourcepub fn pong(timestamp: u64) -> StreamMessage
pub fn pong(timestamp: u64) -> StreamMessage
Create a pong message.
Sourcepub fn subscription_id(&self) -> Option<&str>
pub fn subscription_id(&self) -> Option<&str>
Get the subscription ID if this message has one.
Trait Implementations§
Source§impl Clone for StreamMessage
impl Clone for StreamMessage
Source§fn clone(&self) -> StreamMessage
fn clone(&self) -> StreamMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StreamMessage
impl Debug for StreamMessage
Source§impl<'de> Deserialize<'de> for StreamMessage
impl<'de> Deserialize<'de> for StreamMessage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StreamMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StreamMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for StreamMessage
Source§impl PartialEq for StreamMessage
impl PartialEq for StreamMessage
Source§fn eq(&self, other: &StreamMessage) -> bool
fn eq(&self, other: &StreamMessage) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for StreamMessage
impl Serialize for StreamMessage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for StreamMessage
Auto Trait Implementations§
impl Freeze for StreamMessage
impl RefUnwindSafe for StreamMessage
impl Send for StreamMessage
impl Sync for StreamMessage
impl Unpin for StreamMessage
impl UnsafeUnpin for StreamMessage
impl UnwindSafe for StreamMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.