Struct redis_module::Context
source · [−]pub struct Context {
pub ctx: *mut RedisModuleCtx,
}
Expand description
Context
is a structure that’s designed to give us a high-level interface to
the Redis module API by abstracting away the raw C FFI calls.
Fields
ctx: *mut RedisModuleCtx
Implementations
sourceimpl Context
impl Context
pub fn server_info(&self, section: &str) -> ServerInfo
sourceimpl Context
impl Context
pub const fn new(ctx: *mut RedisModuleCtx) -> Self
pub const fn dummy() -> Self
pub fn log(&self, level: LogLevel, message: &str)
pub fn log_debug(&self, message: &str)
pub fn log_notice(&self, message: &str)
pub fn log_verbose(&self, message: &str)
pub fn log_warning(&self, message: &str)
sourcepub fn auto_memory(&self)
pub fn auto_memory(&self)
Panics
Will panic if RedisModule_AutoMemory
is missing in redismodule.h
sourcepub fn is_keys_position_request(&self) -> bool
pub fn is_keys_position_request(&self) -> bool
Panics
Will panic if RedisModule_IsKeysPositionRequest
is missing in redismodule.h
sourcepub fn key_at_pos(&self, pos: i32)
pub fn key_at_pos(&self, pos: i32)
Panics
Will panic if RedisModule_KeyAtPos
is missing in redismodule.h
pub fn call(&self, command: &str, args: &[&str]) -> RedisResult
pub fn str_as_legal_resp_string(s: &str) -> CString
pub fn reply_simple_string(&self, s: &str) -> Status
pub fn reply_error_string(&self, s: &str) -> Status
sourcepub fn reply(&self, r: RedisResult) -> Status
pub fn reply(&self, r: RedisResult) -> Status
Panics
Will panic if methods used are missing in redismodule.h
pub fn open_key(&self, key: &RedisString) -> RedisKey
pub fn open_key_writable(&self, key: &RedisString) -> RedisKeyWritable
pub fn replicate_verbatim(&self)
pub fn create_string(&self, s: &str) -> RedisString
pub const fn get_raw(&self) -> *mut RedisModuleCtx
sourcepub fn get_redis_version(&self) -> Result<Version, RedisError>
pub fn get_redis_version(&self) -> Result<Version, RedisError>
Returns the redis version either by calling RedisModule_GetServerVersion API, Or if it is not available, by calling “info server” API and parsing the reply
pub fn version_from_info(info: RedisValue) -> Result<Version, RedisError>
pub fn set_module_options(&self, options: ModuleOptions)
Auto Trait Implementations
impl RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more