Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ serde = { version = "1", features = ["derive"] }
nix = { version = "0.26", default-features = false }
cfg-if = "1"
redis-module-macros-internals = { path = "./redismodule-rs-macros-internals" }
strum = {version = "0.27.2",features = ["derive"]}
log = "0.4"

[dev-dependencies]
Expand Down
20 changes: 7 additions & 13 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ impl ParseCallbacks for RedisModuleCallback {
fn int_macro(&self, name: &str, _value: i64) -> Option<IntKind> {
if name.starts_with("REDISMODULE_SUBEVENT_") || name.starts_with("REDISMODULE_EVENT_") {
Some(IntKind::U64)
} else if name.starts_with("REDISMODULE_REPLY_")
|| name.starts_with("REDISMODULE_KEYTYPE_")
|| name.starts_with("REDISMODULE_AUX_")
|| name == "REDISMODULE_OK"
|| name == "REDISMODULE_ERR"
|| name == "REDISMODULE_LIST_HEAD"
|| name == "REDISMODULE_LIST_TAIL"
{
// These values are used as `enum` discriminants, and thus must be `isize`.
Some(IntKind::Custom {
name: "isize",
is_signed: true,
})
} else if name == "REPLY_TYPE"
|| name.starts_with("REDISMODULE_REPLY_") {
// These values are used as `enum` discriminants, and thus must be `isize`.
Some(IntKind::Custom {
name: "i32",
is_signed: true,
})
} else if name.starts_with("REDISMODULE_NOTIFY_") {
Some(IntKind::Int)
} else {
Expand Down
15 changes: 10 additions & 5 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ bitflags! {
}
}

#[derive(Primitive, Debug, PartialEq, Eq)]
#[repr(u32)]
#[derive(Primitive, Debug, PartialEq, Eq, strum::FromRepr)]
pub enum KeyType {
Empty = REDISMODULE_KEYTYPE_EMPTY,
String = REDISMODULE_KEYTYPE_STRING,
Expand All @@ -58,13 +59,15 @@ impl From<c_int> for KeyType {
}
}

#[derive(Primitive, Debug, PartialEq, Eq)]
#[repr(u32)]
#[derive(Primitive, Debug, PartialEq, Eq, strum::FromRepr)]
pub enum Where {
ListHead = REDISMODULE_LIST_HEAD,
ListTail = REDISMODULE_LIST_TAIL,
}

#[derive(Primitive, Debug, PartialEq, Eq)]
#[repr(i32)]
#[derive(Primitive, Debug, PartialEq, Eq, strum::FromRepr)]
pub enum ReplyType {
Unknown = REDISMODULE_REPLY_UNKNOWN,
String = REDISMODULE_REPLY_STRING,
Expand All @@ -86,13 +89,15 @@ impl From<c_int> for ReplyType {
}
}

#[derive(Primitive, Debug, PartialEq, Eq)]
#[repr(u32)]
#[derive(Primitive, Debug, PartialEq, Eq, strum::FromRepr)]
pub enum Aux {
Before = REDISMODULE_AUX_BEFORE_RDB,
After = REDISMODULE_AUX_AFTER_RDB,
}

#[derive(Primitive, Debug, PartialEq, Eq)]
#[repr(u32)]
#[derive(Primitive, Debug, PartialEq, Eq, strum::FromRepr)]
pub enum Status {
Ok = REDISMODULE_OK,
Err = REDISMODULE_ERR,
Expand Down
Loading