Skip to content

Commit

Permalink
fix: panic_on_option_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingtous committed Oct 9, 2022
1 parent e3d9b3d commit b198762
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions monoio-rustls/src/safe_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ impl SafeWrite {

impl io::Write for SafeWrite {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
if self.buffer.is_none() {
return Err(io::ErrorKind::WriteZero.into());
}
// if there is too much data inside the buffer, return WoundBlock
let buffer = self.buffer.as_mut().expect("buffer mut expected");
if !matches!(self.status, WriteStatus::Ok) {
Expand All @@ -233,6 +236,9 @@ impl io::Write for SafeWrite {
}

fn flush(&mut self) -> io::Result<()> {
if self.buffer.is_none() {
return Err(io::ErrorKind::WriteZero.into());
}
let buffer = self.buffer.as_mut().expect("buffer mut expected");
if !matches!(self.status, WriteStatus::Ok) {
match std::mem::replace(&mut self.status, WriteStatus::Ok) {
Expand Down

0 comments on commit b198762

Please sign in to comment.