-
-
Notifications
You must be signed in to change notification settings - Fork 28
Implement gzputc and gzputs #351
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
Conversation
Codecov ReportAttention: Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There are a couple of test coverage gaps that I want to fix, and then I'll move this PR out of draft state. |
libz-rs-sys/src/gz.rs
Outdated
if unsafe { gz_write(state, buf.as_ptr().cast::<c_void>(), 1) } != 1 { | ||
return -1; | ||
} | ||
c & 0xff |
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.
if unsafe { gz_write(state, buf.as_ptr().cast::<c_void>(), 1) } != 1 { | |
return -1; | |
} | |
c & 0xff | |
match unsafe { gz_write(state, buf.as_ptr().cast::<c_void>(), 1) } { | |
1 => c & 0xff, | |
_ => -1, | |
} |
libz-rs-sys/src/gz.rs
Outdated
if put < len as _ { | ||
-1 | ||
} else { | ||
len as _ | ||
} |
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.
if put < len as _ { | |
-1 | |
} else { | |
len as _ | |
} | |
match put.cmp(&len) { | |
Ordering::Less => -1, | |
Ordering::Equal | Ordering::Greater => len as _, | |
} |
libz-rs-sys/src/gz.rs
Outdated
unsafe { | ||
gz_error( | ||
state, | ||
Some((Z_STREAM_ERROR, "string length does not fit in int")), |
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.
using let msg = "..."
should reduce the linecount here
libz-rs-sys/src/gz.rs
Outdated
let have = unsafe { | ||
state | ||
.stream | ||
.next_in | ||
.add(state.stream.avail_in as usize) | ||
.offset_from(state.input) | ||
} as usize; |
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.
We already have this bit of code somewhere else right? Maybe this can be a method on state
?
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 just pushed an update where this is encapsulated in a function. I made a small change to gz_write
to simplify the safety conditions for this function. Let me know if the safety comments make sense.
No description provided.