File tree Expand file tree Collapse file tree 4 files changed +13
-8
lines changed
Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,12 @@ name = "monoio-tls-example"
44version = " 0.1.0"
55
66[dependencies ]
7- monoio = {version = " 0.0.7 " , path = " ../../monoio/monoio " }
7+ monoio = {version = " 0.0.8 " }
88rustls = {version = " 0.20" , features = [" tls12" ]}
99rustls-pemfile = " 1"
1010webpki-roots = " 0.22"
1111
12- monoio-rustls = {version = " 0.0.3 " , path = " ../monoio-rustls" , features = [" tls12" ]}
12+ monoio-rustls = {version = " 0.0.4 " , path = " ../monoio-rustls" , features = [" tls12" ]}
1313
1414[[bin ]]
1515name = " server"
Original file line number Diff line number Diff line change @@ -8,23 +8,23 @@ license = "MIT/Apache-2.0"
88name = " monoio-rustls"
99readme = " README.md"
1010repository = " https://github.com/monoio-rs/monoio-tls"
11- version = " 0.0.3 "
11+ version = " 0.0.4 "
1212
1313[dependencies ]
1414bytes = {version = " 1" }
15- monoio = {version = " 0.0.7 " , default-features = false }
15+ monoio = {version = " 0.0.8 " , default-features = false , features = [ " bytes " ] }
1616rustls = {version = " 0.20" , default-features = false }
1717thiserror = {version = " 1" }
1818
1919[features ]
2020dangerous_configuration = [" rustls/dangerous_configuration" ]
21- default = [" logging" , " tls12" , " unsafe_io " ]
21+ default = [" logging" , " tls12" ]
2222logging = [" rustls/logging" ]
2323tls12 = [" rustls/tls12" ]
2424# Once unsafe_io is enabled, you may not drop the future before it returns ready.
2525# It saves one buffer copy than disabled.
2626unsafe_io = []
2727
2828[dev-dependencies ]
29- monoio = " 0.0.7 "
29+ monoio = { version = " 0.0.8 " , features = [ " bytes " ]}
3030webpki-roots = " 0.22"
Original file line number Diff line number Diff line change 1+ #![ allow( stable_features) ]
12#![ feature( generic_associated_types) ]
23#![ feature( type_alias_impl_trait) ]
34
Original file line number Diff line number Diff line change 11use std:: io;
22
33use bytes:: { Buf , BufMut , BytesMut } ;
4- use monoio:: io:: { AsyncReadRent , AsyncWriteRent } ;
4+ use monoio:: io:: { AsyncReadRent , AsyncWriteRent , AsyncWriteRentExt } ;
55
66const BUFFER_SIZE : usize = 16 * 1024 ;
77
@@ -75,7 +75,7 @@ impl SafeWrite {
7575
7676 // buffer is not empty now. write it.
7777 let buffer = self . buffer . take ( ) . expect ( "buffer ownership expected" ) ;
78- let ( result, buffer) = io. write ( buffer) . await ;
78+ let ( result, buffer) = io. write_all ( buffer) . await ;
7979 self . buffer = Some ( buffer) ;
8080 let written_len = result?;
8181 unsafe { self . buffer . as_mut ( ) . unwrap_unchecked ( ) . advance ( written_len) } ;
@@ -102,6 +102,10 @@ impl io::Write for SafeWrite {
102102 }
103103
104104 fn flush ( & mut self ) -> io:: Result < ( ) > {
105+ let buffer = self . buffer . as_mut ( ) . expect ( "buffer mut expected" ) ;
106+ if !buffer. is_empty ( ) {
107+ return Err ( io:: ErrorKind :: WouldBlock . into ( ) ) ;
108+ }
105109 Ok ( ( ) )
106110 }
107111}
You can’t perform that action at this time.
0 commit comments