File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed
Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " async-pipe"
3- version = " 0.1.2 "
3+ version = " 0.1.3 "
44description = " Creates an asynchronous piped reader and writer pair using tokio.rs"
55homepage = " https://github.com/rousan/async-pipe-rs"
66repository = " https://github.com/rousan/async-pipe-rs"
Original file line number Diff line number Diff 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 ( ) ;
Original file line number Diff line number Diff 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 ( ) ;
You can’t perform that action at this time.
0 commit comments