redis_protocol/types.rs
1use crate::error::RedisParseError;
2use nom::IResult;
3
4/// Alternative alias for `std::ops::Range`.
5pub(crate) type _Range = (usize, usize);
6/// A wrapper type for the nom result type that stores range offsets alongside the buffer.
7pub(crate) type DResult<'a, T> = IResult<(&'a [u8], usize), T, RedisParseError<&'a [u8]>>;
8
9/// Terminating bytes between frames.
10pub const CRLF: &str = "\r\n";
11/// The number of slots in a Redis cluster.
12pub const REDIS_CLUSTER_SLOTS: u16 = 16384;
13/// The prefix on normal pubsub messages.
14///
15/// In RESP2 this may be the first inner frame, and in RESP3 it may be the second inner frame.
16pub const PUBSUB_PREFIX: &str = "message";
17/// The prefix on pubsub messages from a pattern matching subscription.
18///
19/// In RESP2 this may be the first inner frame, and in RESP3 it may be the second inner frame.
20pub const PATTERN_PUBSUB_PREFIX: &str = "pmessage";
21/// The prefix on pubsub messages from a shard channel subscription.
22///
23/// In RESP2 this may be the first inner frame, and in RESP3 it may be the second inner frame.
24pub const SHARD_PUBSUB_PREFIX: &str = "smessage";
25/// Prefix on RESP3 push pubsub messages.
26///
27/// In RESP3 this is the first inner frame in a push pubsub message.
28pub const PUBSUB_PUSH_PREFIX: &str = "pubsub";