pub struct Digest { /* private fields */ }Expand description
Wrap the pointer of a RedisModuleDigest
Implementations§
Source§impl Digest
impl Digest
Sourcepub fn add_string<T: AsRef<str>>(&mut self, s: T)
pub fn add_string<T: AsRef<str>>(&mut self, s: T)
Add a new element to the digest. This function can be called multiple times
one element after the other, for all the elements that constitute a given
data structure. The function call must be followed by the call to
RedisModule_DigestEndSequence eventually, when all the elements that are
always in a given order are added. See the Redis Modules data types
documentation for more info. However this is a quick example that uses Redis
data types as an example.
To add a sequence of unordered elements (for example in the case of a Redis Set), the pattern to use is:
foreach element {
AddElement(element);
EndSequence();
}Because Sets are not ordered, so every element added has a position that does not depend from the other. However if instead our elements are ordered in pairs, like field-value pairs of an Hash, then one should use:
foreach key,value {
AddElement(key);
AddElement(value);
EndSquence();
}Because the key and value will be always in the above order, while instead the single key-value pairs, can appear in any position into a Redis hash.
A list of ordered elements would be implemented with:
foreach element {
AddElement(element);
}
EndSequence();Sourcepub fn add_integer(&mut self, i: i64)
pub fn add_integer(&mut self, i: i64)
Like Digest::digest_add_string_buffer but takes a long long as input
that gets converted into a string before adding it to the digest.
Sourcepub fn end_sequeue(&mut self)
pub fn end_sequeue(&mut self)
See Context:add_string_buffer