File tree Expand file tree Collapse file tree 6 files changed +50
-0
lines changed
embedded-io-async/src/impls Expand file tree Collapse file tree 6 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,13 @@ impl Write for &mut [u8] {
2424 * self = b;
2525 Ok ( amt)
2626 }
27+
28+ #[ inline]
29+ async fn write_all ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
30+ if self . len ( ) < buf. len ( ) {
31+ return Err ( SliceWriteError :: Full ) ;
32+ }
33+ self . write ( buf) . await ?;
34+ Ok ( ( ) )
35+ }
2736}
Original file line number Diff line number Diff line change @@ -22,6 +22,17 @@ impl Read for &[u8] {
2222 * self = b;
2323 Ok ( amt)
2424 }
25+
26+ async fn read_exact (
27+ & mut self ,
28+ buf : & mut [ u8 ] ,
29+ ) -> Result < ( ) , embedded_io:: ReadExactError < Self :: Error > > {
30+ if self . len ( ) < buf. len ( ) {
31+ return Err ( crate :: ReadExactError :: UnexpectedEof ) ;
32+ }
33+ self . read ( buf) . await ?;
34+ Ok ( ( ) )
35+ }
2536}
2637
2738impl BufRead for & [ u8 ] {
Original file line number Diff line number Diff line change @@ -9,4 +9,10 @@ impl Write for Vec<u8> {
99 self . extend_from_slice ( buf) ;
1010 Ok ( buf. len ( ) )
1111 }
12+
13+ #[ inline]
14+ async fn write_all ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
15+ self . write ( buf) . await ?;
16+ Ok ( ( ) )
17+ }
1218}
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ impl Write for &mut [u8] {
4242 Ok ( amt)
4343 }
4444
45+ #[ inline]
46+ fn write_all ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
47+ if self . len ( ) < buf. len ( ) {
48+ return Err ( SliceWriteError :: Full ) ;
49+ }
50+ self . write ( buf) ?;
51+ Ok ( ( ) )
52+ }
53+
4554 #[ inline]
4655 fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
4756 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ impl Read for &[u8] {
2626 * self = b;
2727 Ok ( amt)
2828 }
29+
30+ #[ inline]
31+ fn read_exact ( & mut self , buf : & mut [ u8 ] ) -> Result < ( ) , crate :: ReadExactError < Self :: Error > > {
32+ if self . len ( ) < buf. len ( ) {
33+ return Err ( crate :: ReadExactError :: UnexpectedEof ) ;
34+ }
35+ self . read ( buf) ?;
36+ Ok ( ( ) )
37+ }
2938}
3039
3140impl BufRead for & [ u8 ] {
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ impl Write for Vec<u8> {
1414 Ok ( buf. len ( ) )
1515 }
1616
17+ #[ inline]
18+ fn write_all ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
19+ self . write ( buf) ?;
20+ Ok ( ( ) )
21+ }
22+
1723 #[ inline]
1824 fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
1925 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments