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] {
24
24
* self = b;
25
25
Ok ( amt)
26
26
}
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
+ }
27
36
}
Original file line number Diff line number Diff line change @@ -22,6 +22,17 @@ impl Read for &[u8] {
22
22
* self = b;
23
23
Ok ( amt)
24
24
}
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
+ }
25
36
}
26
37
27
38
impl BufRead for & [ u8 ] {
Original file line number Diff line number Diff line change @@ -9,4 +9,10 @@ impl Write for Vec<u8> {
9
9
self . extend_from_slice ( buf) ;
10
10
Ok ( buf. len ( ) )
11
11
}
12
+
13
+ #[ inline]
14
+ async fn write_all ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
15
+ self . write ( buf) . await ?;
16
+ Ok ( ( ) )
17
+ }
12
18
}
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ impl Write for &mut [u8] {
42
42
Ok ( amt)
43
43
}
44
44
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
+
45
54
#[ inline]
46
55
fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
47
56
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ impl Read for &[u8] {
26
26
* self = b;
27
27
Ok ( amt)
28
28
}
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
+ }
29
38
}
30
39
31
40
impl BufRead for & [ u8 ] {
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ impl Write for Vec<u8> {
14
14
Ok ( buf. len ( ) )
15
15
}
16
16
17
+ #[ inline]
18
+ fn write_all ( & mut self , buf : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
19
+ self . write ( buf) ?;
20
+ Ok ( ( ) )
21
+ }
22
+
17
23
#[ inline]
18
24
fn flush ( & mut self ) -> Result < ( ) , Self :: Error > {
19
25
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments