@@ -218,12 +218,15 @@ impl RedisKeyWritable {
218218 Self { ctx, key_inner }
219219 }
220220
221- /// Detects whether the value stored in a Redis key is empty .
221+ /// Returns `true` if the key is of type [KeyType::Empty] .
222222 ///
223- /// Note that an empty key can be reliably detected by looking for a null
224- /// as you open the key in read mode, but when asking for write Redis
225- /// returns a non-null pointer to allow us to write to even an empty key,
226- /// so we have to check the key's value instead.
223+ /// # Note
224+ ///
225+ /// An empty key can be reliably detected by looking for a null
226+ /// as the key is opened [RedisKeyWritable::open] in read mode,
227+ /// but when asking for a write, Redis returns a non-null pointer
228+ /// to allow to write to even an empty key. In that case, the key's
229+ /// value should be checked manually instead:
227230 ///
228231 /// ```
229232 /// use redis_module::key::RedisKeyWritable;
@@ -235,6 +238,11 @@ impl RedisKeyWritable {
235238 /// Ok(is_empty)
236239 /// }
237240 /// ```
241+ #[ must_use]
242+ pub fn is_empty ( & self ) -> bool {
243+ self . key_type ( ) == KeyType :: Empty
244+ }
245+
238246 pub fn as_string_dma ( & self ) -> Result < StringDMA , RedisError > {
239247 StringDMA :: new ( self )
240248 }
@@ -361,11 +369,6 @@ impl RedisKeyWritable {
361369 unsafe { raw:: RedisModule_KeyType . unwrap ( ) ( self . key_inner ) } . into ( )
362370 }
363371
364- #[ must_use]
365- pub fn is_empty ( & self ) -> bool {
366- self . key_type ( ) == KeyType :: Empty
367- }
368-
369372 pub fn open_with_redis_string (
370373 ctx : * mut raw:: RedisModuleCtx ,
371374 key : * mut raw:: RedisModuleString ,
0 commit comments