File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
52
52
(#[ 1553] ( https://github.com/nix-rust/nix/pull/1553 ) )
53
53
- Added ` ENOTRECOVERABLE ` and ` EOWNERDEAD ` error codes on DragonFly.
54
54
(#[ 1665] ( https://github.com/nix-rust/nix/pull/1665 ) )
55
+ - Implemented ` Read ` and ` Write ` for ` &PtyMaster `
56
+ (#[ 1664] ( https://github.com/nix-rust/nix/pull/1664 ) )
55
57
56
58
### Changed
57
59
Original file line number Diff line number Diff line change @@ -95,6 +95,21 @@ impl io::Write for PtyMaster {
95
95
}
96
96
}
97
97
98
+ impl io:: Read for & PtyMaster {
99
+ fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
100
+ unistd:: read ( self . 0 , buf) . map_err ( io:: Error :: from)
101
+ }
102
+ }
103
+
104
+ impl io:: Write for & PtyMaster {
105
+ fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
106
+ unistd:: write ( self . 0 , buf) . map_err ( io:: Error :: from)
107
+ }
108
+ fn flush ( & mut self ) -> io:: Result < ( ) > {
109
+ Ok ( ( ) )
110
+ }
111
+ }
112
+
98
113
/// Grant access to a slave pseudoterminal (see
99
114
/// [`grantpt(3)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/grantpt.html))
100
115
///
Original file line number Diff line number Diff line change @@ -170,6 +170,11 @@ fn test_read_ptty_pair() {
170
170
slave. write_all ( b"hello" ) . unwrap ( ) ;
171
171
master. read_exact ( & mut buf) . unwrap ( ) ;
172
172
assert_eq ! ( & buf, b"hello" ) ;
173
+
174
+ let mut master = & master;
175
+ slave. write_all ( b"hello" ) . unwrap ( ) ;
176
+ master. read_exact ( & mut buf) . unwrap ( ) ;
177
+ assert_eq ! ( & buf, b"hello" ) ;
173
178
}
174
179
175
180
/// Test `io::Write` on the PTTY master
@@ -182,6 +187,11 @@ fn test_write_ptty_pair() {
182
187
master. write_all ( b"adios" ) . unwrap ( ) ;
183
188
slave. read_exact ( & mut buf) . unwrap ( ) ;
184
189
assert_eq ! ( & buf, b"adios" ) ;
190
+
191
+ let mut master = & master;
192
+ master. write_all ( b"adios" ) . unwrap ( ) ;
193
+ slave. read_exact ( & mut buf) . unwrap ( ) ;
194
+ assert_eq ! ( & buf, b"adios" ) ;
185
195
}
186
196
187
197
#[ test]
You can’t perform that action at this time.
0 commit comments