-
Notifications
You must be signed in to change notification settings - Fork 1
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
conversations: remember last seen timestamps #30
Conversation
135af84
to
ff7b510
Compare
@isra17 review plz |
407602f
to
d0af981
Compare
ping @isra17! After our discussion, I have implemented persistent timestamps. It looks like this in the buddylist:
I use strings for the timestamp because they are int64. |
d0af981
to
4b87661
Compare
src/purple/blist.rs
Outdated
pub fn get_string(&mut self, c_key: &CString) -> Option<String> { | ||
let c_str = | ||
unsafe { purple_sys::purple_blist_node_get_string(self.0.as_ptr(), c_key.as_ptr()) }; | ||
if c_str.is_null() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NonNull::new(c_str)
.map(|p| {
CStr::from_ptr(p.as_ptr() as *const c_char)
.to_str()
.unwrap()
})
? (This would return an Option<&str>
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't seem to create the NonNull with the c_value.
Am I doing something wrong?
pub fn get_string(&mut self, key: &str) -> Option<&str> {
let c_key = CString::new(key).unwrap();
let mut c_value =
unsafe { purple_sys::purple_blist_node_get_string(self.0.as_ptr(), c_key.as_ptr()) };
NonNull::new(c_value).map(|p| {
CStr::from_ptr(p.as_ptr() as *const c_char)
.to_str()
.unwrap()
})
}
= note: expected raw pointer `*mut _`
found raw pointer `*const i8`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add NonNull::new(c_value as *mut c_char)
I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
4b87661
to
cecccf3
Compare
68797cf
to
f8d1cc8
Compare
f8d1cc8
to
5653397
Compare
LGTM! |
Or user won't see the message.