Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add RESP3 new APIs #280

Merged
merged 26 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
66393c6
add RESP3 new APIs
gkorland Feb 8, 2023
abf94ae
handle Map, Set, Bool
gkorland Feb 8, 2023
8f3ddd4
add missing file
gkorland Feb 8, 2023
a4d462a
add clippy allow
gkorland Feb 8, 2023
5cc389f
fmt code
gkorland Feb 9, 2023
5d5417b
add example and test
gkorland Feb 9, 2023
3185635
add example
gkorland Feb 9, 2023
3a3c978
fix fail back case for array
gkorland Feb 9, 2023
18d4ac0
uncomment method compare
gkorland Feb 9, 2023
fca914b
Merge branch 'master' into gkorland-resp3-api
gkorland Feb 9, 2023
0bbe4aa
set uniqe port for the test
gkorland Feb 12, 2023
50b3e89
Merge branch 'master' into gkorland-resp3-api
gkorland Feb 12, 2023
70adf43
Merge branch 'master' into gkorland-resp3-api
MeirShpilraien Mar 23, 2023
7f44061
Added resp3 to CallReply and refactor CallReply to be more rusty
MeirShpilraien Mar 23, 2023
7d052ce
Added borrow API to CallReply. Document CallReply API.
MeirShpilraien Mar 24, 2023
b341954
Review fixes
MeirShpilraien Mar 25, 2023
071387c
Merge branch 'master' into gkorland-resp3-api
MeirShpilraien Mar 26, 2023
7feceec
Merge branch 'master' into gkorland-resp3-api
MeirShpilraien Mar 26, 2023
022b1be
Review fixes.
MeirShpilraien Mar 26, 2023
447f8ab
Merge branch 'master' into gkorland-resp3-api
MeirShpilraien Mar 26, 2023
83e020c
Review fixes.
MeirShpilraien Apr 2, 2023
674dbfa
Review fixes
MeirShpilraien Apr 4, 2023
f2f27e7
Use from_utf8_lossy on Display instead of printing NULL
MeirShpilraien Apr 5, 2023
d5e59eb
Format fixes.
MeirShpilraien Apr 5, 2023
84a8232
Review fixes.
MeirShpilraien Apr 5, 2023
c2395e8
Review fixes
MeirShpilraien Apr 5, 2023
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
81 changes: 70 additions & 11 deletions src/context/call_reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ impl<'root> Drop for StringCallReply<'root> {
}
}

impl<'root> Debug for StringCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.as_bytes())
iddm marked this conversation as resolved.
Show resolved Hide resolved
}
}

pub struct ErrorCallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand All @@ -59,23 +65,18 @@ impl<'root> ErrorCallReply<'root> {
}
}

impl<'root> Debug for ErrorCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(
f,
"ErrorCallReply: {}.",
self.to_string()
.unwrap_or("can not transform data into String".to_string())
)
}
}

impl<'root> Drop for ErrorCallReply<'root> {
fn drop(&mut self) {
free_call_reply(self.reply.as_ptr());
}
}

impl<'root> Debug for ErrorCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.to_string())
iddm marked this conversation as resolved.
Show resolved Hide resolved
}
}

pub struct I64CallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand All @@ -94,6 +95,12 @@ impl<'root> Drop for I64CallReply<'root> {
}
}

impl<'root> Debug for I64CallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.to_i64())
iddm marked this conversation as resolved.
Show resolved Hide resolved
}
}

pub struct ArrayCallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand Down Expand Up @@ -144,6 +151,13 @@ impl<'root, 'curr> Iterator for ArrayCallReplyIterator<'root, 'curr> {
}
}

impl<'root> Debug for ArrayCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let children: Vec<CallResult> = self.iter().collect();
write!(f, "{:?}", children)
iddm marked this conversation as resolved.
Show resolved Hide resolved
}
}

pub struct NullCallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand All @@ -155,6 +169,12 @@ impl<'root> Drop for NullCallReply<'root> {
}
}

impl<'root> Debug for NullCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "Null")
iddm marked this conversation as resolved.
Show resolved Hide resolved
}
}

pub struct MapCallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand Down Expand Up @@ -209,6 +229,13 @@ impl<'root> Drop for MapCallReply<'root> {
}
}

impl<'root> Debug for MapCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let elements: Vec<(CallResult, CallResult)> = self.iter().collect();
write!(f, "{:?}", elements)
}
}

iddm marked this conversation as resolved.
Show resolved Hide resolved
pub struct SetCallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand Down Expand Up @@ -258,6 +285,13 @@ impl<'root> Drop for SetCallReply<'root> {
}
}

impl<'root> Debug for SetCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let elements: Vec<CallResult> = self.iter().collect();
write!(f, "{:?}", elements)
}
}
iddm marked this conversation as resolved.
Show resolved Hide resolved

pub struct BoolCallReply<'root> {
MeirShpilraien marked this conversation as resolved.
Show resolved Hide resolved
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand All @@ -276,6 +310,12 @@ impl<'root> Drop for BoolCallReply<'root> {
}
}

impl<'root> Debug for BoolCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.to_bool())
}
}
iddm marked this conversation as resolved.
Show resolved Hide resolved

pub struct DoubleCallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand All @@ -294,6 +334,12 @@ impl<'root> Drop for DoubleCallReply<'root> {
}
}

impl<'root> Debug for DoubleCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.to_double())
}
}
iddm marked this conversation as resolved.
Show resolved Hide resolved

pub struct BigNumberCallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand All @@ -313,6 +359,12 @@ impl<'root> Drop for BigNumberCallReply<'root> {
}
}

impl<'root> Debug for BigNumberCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.to_string())
}
}
iddm marked this conversation as resolved.
Show resolved Hide resolved

pub struct VerbatimStringCallReply<'root> {
reply: NonNull<RedisModuleCallReply>,
_dummy: PhantomData<&'root ()>,
Expand Down Expand Up @@ -355,6 +407,13 @@ impl<'root> Drop for VerbatimStringCallReply<'root> {
}
}

impl<'root> Debug for VerbatimStringCallReply<'root> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.to_parts())
}
}
iddm marked this conversation as resolved.
Show resolved Hide resolved

#[derive(Debug)]
pub enum CallReply<'root> {
Unknown,
I64(I64CallReply<'root>),
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ pub use crate::context::thread_safe::{DetachedFromClient, ThreadSafeContext};
#[cfg(feature = "experimental-api")]
pub use crate::raw::NotifyEvent;

pub use crate::context::call_reply::{CallReply, CallResult};
pub use crate::configuration::ConfigurationValue;
pub use crate::configuration::EnumConfigurationValue;
pub use crate::context::call_reply::{CallReply, CallResult};
pub use crate::context::keys_cursor::KeysCursor;
pub use crate::context::server_events;
pub use crate::context::thread_safe::RedisGILGuard;
Expand Down