Fixing return in get_ttl and get_expiration #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is supposed to resolve issue #63
It fixes 3 issues :
Problems seems to be in src/lib.rs - pub fn get_ttl(&self) -> Option<u32> and pub fn get_expiration(&self) -> Expiration
Abount the first issue I think the concept of TTL implemented in that function's body is wrong.
It considers TTL to be number of seconds since CITRUSLEAF_EPOCH but in fact it is not.
TTL in secs variable is the amount of seconds since the present moment when the record will expire.
Due to this conception misunderstanding all the code that adds it to CITRUSLEAF_EPOCH and compares it with the now time is not necesary. In fact the following check if expiration > now never gets true and the functions always return (1 as u32).into();
Second issue is due to wrong comparison as NEVER_EXPIRE is not 0 but 0xFFFFFFFF. So when ttl = NEVER_EXPIRE it then actually goes to the second match and subsequently satisfy if expiration > now and efectively returns NEVER_EXPIRE + CITRUSLEAF_EPOCH - NOW. I was thinking to make get_ttl method return i32 type value in order to represent NEVER_EXPIRE as -1 but finally I decided that it can return NULL when NEVER_EXPIRE otherwise return u32 as the original TTL type use.