From 410204a41e7f6e244e60a36de87c8f20aeff991a Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 17 Nov 2018 18:46:26 -0800 Subject: [PATCH] Framed::is_write_buf_empty() checks if write buffer is flushed --- CHANGES.md | 6 ++++++ Cargo.toml | 2 +- src/codec/framed.rs | 5 +++++ src/codec/framed_write.rs | 9 +++++++++ src/server/mod.rs | 2 +- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 58e683795..8c16169cb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/Cargo.toml b/Cargo.toml index b7f1c1e0c..3ebfdaf15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-net" -version = "0.2.2" +version = "0.2.3" authors = ["Nikolay Kim "] description = "Actix net - framework for the compisible network services for Rust (experimental)" readme = "README.md" diff --git a/src/codec/framed.rs b/src/codec/framed.rs index fcf5d2dae..3c92ee54c 100644 --- a/src/codec/framed.rs +++ b/src/codec/framed.rs @@ -135,6 +135,11 @@ impl Framed { &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() diff --git a/src/codec/framed_write.rs b/src/codec/framed_write.rs index 02ea5738f..8d4fe15f7 100644 --- a/src/codec/framed_write.rs +++ b/src/codec/framed_write.rs @@ -77,6 +77,11 @@ impl FramedWrite { 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 FramedWrite @@ -194,6 +199,10 @@ impl FramedWrite2 { pub fn is_full(&self) -> bool { self.buffer.len() >= self.high_watermark } + + pub fn is_empty(&self) -> bool { + self.buffer.is_empty() + } } impl FramedWrite2 diff --git a/src/server/mod.rs b/src/server/mod.rs index d84f87dd6..24d20b15d 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -45,4 +45,4 @@ impl Token { self.0 += 1; token } -} \ No newline at end of file +}