Struct redis::Msg
[−]
[src]
pub struct Msg { // some fields omitted }
Represents a pubsub message.
Methods
impl Msg
This holds the data that comes from listening to a pubsub connection. It only contains actual message data.
fn get_channel<T: FromRedisValue>(&self) -> RedisResult<T>
Returns the channel this message came on.
fn get_channel_name(&self) -> &str
Convenience method to get a string version of the channel. Unless
your channel contains non utf-8 bytes you can always use this
method. If the channel is not a valid string (which really should
not happen) then the return value is "?"
.
fn get_payload<T: FromRedisValue>(&self) -> RedisResult<T>
Returns the message's payload in a specific format.
fn get_payload_bytes(&self) -> &[u8]
Returns the bytes that are the message's payload. This can be used
as an alternative to the get_payload
function if you are interested
in the raw bytes in it.
fn from_pattern(&self) -> bool
Returns true if the message was constructed from a pattern subscription.
fn get_pattern<T: FromRedisValue>(&self) -> RedisResult<T>
If the message was constructed from a message pattern this can be
used to find out which one. It's recommended to match against
an Option<String>
so that you do not need to use from_pattern
to figure out if a pattern was set.