Skip to content

Commit

Permalink
Framed::is_write_buf_empty() checks if write buffer is flushed
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Nov 18, 2018
1 parent 29fe995 commit 410204a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

## [0.2.3] - 2018-11-17

### Added

* Framed::is_write_buf_empty() checks if write buffer is flushed

## [0.2.2] - 2018-11-14

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-net"
version = "0.2.2"
version = "0.2.3"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix net - framework for the compisible network services for Rust (experimental)"
readme = "README.md"
Expand Down
5 changes: 5 additions & 0 deletions src/codec/framed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ impl<T, U> Framed<T, U> {
&mut self.inner.get_mut().get_mut().0
}

/// Check if write buffer is empty.
pub fn is_write_buf_empty(&self) -> bool {
self.inner.get_ref().is_empty()
}

/// Check if write buffer is full.
pub fn is_write_buf_full(&self) -> bool {
self.inner.get_ref().is_full()
Expand Down
9 changes: 9 additions & 0 deletions src/codec/framed_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ impl<T, E> FramedWrite<T, E> {
pub fn is_full(&self) -> bool {
self.inner.is_full()
}

/// Check if write buffer is empty.
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
}

impl<T, E> FramedWrite<T, E>
Expand Down Expand Up @@ -194,6 +199,10 @@ impl<T> FramedWrite2<T> {
pub fn is_full(&self) -> bool {
self.buffer.len() >= self.high_watermark
}

pub fn is_empty(&self) -> bool {
self.buffer.is_empty()
}
}

impl<T> FramedWrite2<T>
Expand Down
2 changes: 1 addition & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ impl Token {
self.0 += 1;
token
}
}
}

0 comments on commit 410204a

Please sign in to comment.