redis_module/context/
blocked.rs1use std::ptr;
2
3use crate::raw;
4use crate::Context;
5
6pub struct BlockedClient {
7 pub(crate) inner: *mut raw::RedisModuleBlockedClient,
8}
9
10unsafe impl Send for BlockedClient {}
12
13impl Drop for BlockedClient {
14 fn drop(&mut self) {
15 unsafe { raw::RedisModule_UnblockClient.unwrap()(self.inner, ptr::null_mut()) };
16 }
17}
18
19impl Context {
20 #[must_use]
21 pub fn block_client(&self) -> BlockedClient {
22 let blocked_client = unsafe {
23 raw::RedisModule_BlockClient.unwrap()(
24 self.ctx, None, None, None, 0,
28 )
29 };
30
31 BlockedClient {
32 inner: blocked_client,
33 }
34 }
35}