Skip to content

Commit 67d2f43

Browse files
committed
Merge branch 'release/0.1.3'
2 parents 3ee5760 + 273107d commit 67d2f43

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "async-pipe"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "Creates an asynchronous piped reader and writer pair using tokio.rs"
55
homepage = "https://github.com/rousan/async-pipe-rs"
66
repository = "https://github.com/rousan/async-pipe-rs"

src/reader.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ impl PipeReader {
3030
}
3131
}
3232

33+
/// It returns true if the next data chunk is written by the writer and consumed by the reader; Otherwise it returns false.
34+
pub fn is_flushed(&self) -> io::Result<bool> {
35+
let state = match self.state.lock() {
36+
Ok(s) => s,
37+
Err(err) => {
38+
return Err(io::Error::new(
39+
io::ErrorKind::Other,
40+
format!(
41+
"{}: PipeReader: Failed to lock the channel state: {}",
42+
env!("CARGO_PKG_NAME"),
43+
err
44+
),
45+
));
46+
}
47+
};
48+
49+
Ok(state.done_cycle)
50+
}
51+
3352
fn wake_writer_half(&self, state: &State) {
3453
if let Some(ref waker) = state.writer_waker {
3554
waker.clone().wake();

src/writer.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ impl PipeWriter {
3030
}
3131
}
3232

33+
/// It returns true if the next data chunk is written and consumed by the reader; Otherwise it returns false.
34+
pub fn is_flushed(&self) -> io::Result<bool> {
35+
let state = match self.state.lock() {
36+
Ok(s) => s,
37+
Err(err) => {
38+
return Err(io::Error::new(
39+
io::ErrorKind::Other,
40+
format!(
41+
"{}: PipeWriter: Failed to lock the channel state: {}",
42+
env!("CARGO_PKG_NAME"),
43+
err
44+
),
45+
));
46+
}
47+
};
48+
49+
Ok(state.done_cycle)
50+
}
51+
3352
fn wake_reader_half(&self, state: &State) {
3453
if let Some(ref waker) = state.reader_waker {
3554
waker.clone().wake();

0 commit comments

Comments
 (0)