|
1 | 1 | use std::ffi::CString; |
2 | | -use std::os::raw::{c_char, c_int, c_long}; |
| 2 | +use std::os::raw::{c_char, c_int, c_long, c_longlong}; |
3 | 3 | use std::ptr; |
4 | 4 |
|
5 | 5 | use crate::key::{RedisKey, RedisKeyWritable}; |
6 | | -use crate::raw; |
7 | 6 | use crate::raw::ModuleOptions; |
8 | | -use crate::LogLevel; |
| 7 | +use crate::{add_info_field_long_long, add_info_field_str, raw, Status}; |
| 8 | +use crate::{add_info_section, LogLevel}; |
9 | 9 | use crate::{RedisError, RedisResult, RedisString, RedisValue}; |
10 | 10 |
|
11 | 11 | #[cfg(feature = "experimental-api")] |
@@ -286,3 +286,36 @@ impl Context { |
286 | 286 | unsafe { raw::RedisModule_SetModuleOptions.unwrap()(self.ctx, options.bits()) }; |
287 | 287 | } |
288 | 288 | } |
| 289 | + |
| 290 | +pub struct InfoContext { |
| 291 | + pub ctx: *mut raw::RedisModuleInfoCtx, |
| 292 | +} |
| 293 | + |
| 294 | +impl InfoContext { |
| 295 | + pub fn new(ctx: *mut raw::RedisModuleInfoCtx) -> Self { |
| 296 | + Self { ctx } |
| 297 | + } |
| 298 | + |
| 299 | + pub fn add_info_section( |
| 300 | + &self, |
| 301 | + name: Option<&str>, // assume NULL terminated |
| 302 | + ) -> Status { |
| 303 | + add_info_section(self.ctx, name) |
| 304 | + } |
| 305 | + |
| 306 | + pub fn add_info_field_str( |
| 307 | + &self, |
| 308 | + name: &str, // assume NULL terminated |
| 309 | + content: &str, |
| 310 | + ) -> Status { |
| 311 | + add_info_field_str(self.ctx, name, content) |
| 312 | + } |
| 313 | + |
| 314 | + pub fn add_info_field_long_long( |
| 315 | + &self, |
| 316 | + name: &str, // assume NULL terminated |
| 317 | + value: c_longlong, |
| 318 | + ) -> Status { |
| 319 | + add_info_field_long_long(self.ctx, name, value) |
| 320 | + } |
| 321 | +} |
0 commit comments