Defrag

Struct Defrag 

Source
pub struct Defrag {
    pub defrag_ctx: *mut RedisModuleDefragCtx,
}
Expand description

Defrag is a high-level rust interface to the Valkey module C API abstracting away the raw C ffi calls.

Fields§

§defrag_ctx: *mut RedisModuleDefragCtx

Implementations§

Source§

impl Defrag

Source

pub const fn new(defrag_ctx: *mut RedisModuleDefragCtx) -> Self

Source

pub unsafe fn alloc(&self, ptr: *mut c_void) -> *mut c_void

§Returns a pointer to the new alloction of the data, if no defragmentation was needed a null pointer is returned
§Panics

Will panic if RedisModule_DefragAlloc is missing in redismodule.h

Source

pub unsafe fn set_cursor(&self, cursor: u64) -> Status

§Sets a cursor on the last item defragged so that on the next defrag cycle, the Module can resume from that position using get_cursor.
§Should only be called if should_stop_defrag has returned true and the defrag callback is about to exit without fully iterating its data type.
§Panics

Will panic if RedisModule_DefragCursorSet is missing in redismodule.h

Source

pub unsafe fn get_cursor(&self) -> Option<u64>

§Returns the cursor value that has been previously stored using set_cursor
§Panics

Will panic if RedisModule_DefragCursorGet is missing in redismodule.h

Source

pub unsafe fn should_stop_defrag(&self) -> bool

§Returns true if the engine has been defragging for too long and the Module should need to stop.
§Returns false otherwise for the Module to know it can continue its work.
§Panics

Will panic if RedisModule_DefragShouldStop is missing in redismodule.h

Source

pub unsafe fn get_key_name_from_defrag_context( &self, ) -> *const RedisModuleString

§Returns the name of the key being processed.
§If the key name isn’t available this will return NULL instead
§Panics

Will panic if RedisModule_GetKeyNameFromDefragCtx is missing in redismodule.h

Source

pub unsafe fn get_db_id_from_defrag_context(&self) -> i32

§Returns the database id of the key that is currently being defragged.
§If this information isn’t available it will return -1
§Panics

Will panic if RedisModule_GetDbIdFromDefragCtx is missing in redismodule.h

Auto Trait Implementations§

§

impl Freeze for Defrag

§

impl RefUnwindSafe for Defrag

§

impl !Send for Defrag

§

impl !Sync for Defrag

§

impl Unpin for Defrag

§

impl UnwindSafe for Defrag

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.