@@ -127,7 +127,7 @@ pub trait WriteVolatile {
127
127
// We explicitly implement our traits for [`std::fs::File`] and [`std::os::unix::net::UnixStream`]
128
128
// instead of providing blanket implementation for [`AsRawFd`] due to trait coherence limitations: A
129
129
// blanket implementation would prevent us from providing implementations for `&mut [u8]` below, as
130
- // "an upstream crate could implement AsRawFd for &mut [u8]` .
130
+ // "an upstream crate could implement AsRawFd for &mut [u8]" .
131
131
132
132
macro_rules! impl_read_write_volatile_for_raw_fd {
133
133
( $raw_fd_ty: ty) => {
@@ -141,6 +141,16 @@ macro_rules! impl_read_write_volatile_for_raw_fd {
141
141
}
142
142
}
143
143
144
+ #[ cfg( feature = "rawfd" ) ]
145
+ impl ReadVolatile for & $raw_fd_ty {
146
+ fn read_volatile<B : BitmapSlice >(
147
+ & mut self ,
148
+ buf: & mut VolatileSlice <B >,
149
+ ) -> Result <usize , VolatileMemoryError > {
150
+ read_volatile_raw_fd( * self , buf)
151
+ }
152
+ }
153
+
144
154
#[ cfg( feature = "rawfd" ) ]
145
155
impl WriteVolatile for $raw_fd_ty {
146
156
fn write_volatile<B : BitmapSlice >(
@@ -150,6 +160,16 @@ macro_rules! impl_read_write_volatile_for_raw_fd {
150
160
write_volatile_raw_fd( self , buf)
151
161
}
152
162
}
163
+
164
+ #[ cfg( feature = "rawfd" ) ]
165
+ impl WriteVolatile for & $raw_fd_ty {
166
+ fn write_volatile<B : BitmapSlice >(
167
+ & mut self ,
168
+ buf: & VolatileSlice <B >,
169
+ ) -> Result <usize , VolatileMemoryError > {
170
+ write_volatile_raw_fd( * self , buf)
171
+ }
172
+ }
153
173
} ;
154
174
}
155
175
@@ -163,6 +183,16 @@ impl WriteVolatile for Stdout {
163
183
}
164
184
}
165
185
186
+ #[ cfg( feature = "rawfd" ) ]
187
+ impl WriteVolatile for & Stdout {
188
+ fn write_volatile < B : BitmapSlice > (
189
+ & mut self ,
190
+ buf : & VolatileSlice < B > ,
191
+ ) -> Result < usize , VolatileMemoryError > {
192
+ write_volatile_raw_fd ( * self , buf)
193
+ }
194
+ }
195
+
166
196
impl_read_write_volatile_for_raw_fd ! ( std:: fs:: File ) ;
167
197
impl_read_write_volatile_for_raw_fd ! ( std:: net:: TcpStream ) ;
168
198
impl_read_write_volatile_for_raw_fd ! ( std:: os:: unix:: net:: UnixStream ) ;
@@ -175,7 +205,7 @@ impl_read_write_volatile_for_raw_fd!(std::os::fd::BorrowedFd<'_>);
175
205
/// Returns the numbers of bytes read.
176
206
#[ cfg( feature = "rawfd" ) ]
177
207
fn read_volatile_raw_fd < Fd : AsRawFd > (
178
- raw_fd : & mut Fd ,
208
+ raw_fd : & Fd ,
179
209
buf : & mut VolatileSlice < impl BitmapSlice > ,
180
210
) -> Result < usize , VolatileMemoryError > {
181
211
let fd = raw_fd. as_raw_fd ( ) ;
@@ -206,7 +236,7 @@ fn read_volatile_raw_fd<Fd: AsRawFd>(
206
236
/// Returns the numbers of bytes written.
207
237
#[ cfg( feature = "rawfd" ) ]
208
238
fn write_volatile_raw_fd < Fd : AsRawFd > (
209
- raw_fd : & mut Fd ,
239
+ raw_fd : & Fd ,
210
240
buf : & VolatileSlice < impl BitmapSlice > ,
211
241
) -> Result < usize , VolatileMemoryError > {
212
242
let fd = raw_fd. as_raw_fd ( ) ;
0 commit comments