@@ -55,7 +55,7 @@ impl Error for ErrorKind {
55
55
}
56
56
}
57
57
58
- /// Base trait for all IO traits.
58
+ /// Base trait for all IO traits, defining the error type .
59
59
///
60
60
/// All IO operations of all traits return the error defined in this trait.
61
61
///
@@ -64,12 +64,12 @@ impl Error for ErrorKind {
64
64
/// This is very convenient when writing generic code, it means you have to
65
65
/// handle a single error type `T::Error`, instead of `<T as Read>::Error` and `<T as Write>::Error`
66
66
/// which might be different types.
67
- pub trait Io {
67
+ pub trait ErrorType {
68
68
/// Error type of all the IO operations on this type.
69
69
type Error : Error ;
70
70
}
71
71
72
- impl < T : ?Sized + crate :: Io > crate :: Io for & mut T {
72
+ impl < T : ?Sized + crate :: ErrorType > crate :: ErrorType for & mut T {
73
73
type Error = T :: Error ;
74
74
}
75
75
@@ -150,7 +150,7 @@ impl<E: fmt::Debug> std::error::Error for WriteAllError<E> {}
150
150
/// Blocking reader.
151
151
///
152
152
/// Semantics are the same as [`std::io::Read`], check its documentation for details.
153
- pub trait Read : crate :: Io {
153
+ pub trait Read : crate :: ErrorType {
154
154
/// Pull some bytes from this source into the specified buffer, returning how many bytes were read.
155
155
fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , Self :: Error > ;
156
156
@@ -174,7 +174,7 @@ pub trait Read: crate::Io {
174
174
/// Blocking buffered reader.
175
175
///
176
176
/// Semantics are the same as [`std::io::BufRead`], check its documentation for details.
177
- pub trait BufRead : crate :: Io {
177
+ pub trait BufRead : crate :: ErrorType {
178
178
/// Return the contents of the internal buffer, filling it with more data from the inner reader if it is empty.
179
179
fn fill_buf ( & mut self ) -> Result < & [ u8 ] , Self :: Error > ;
180
180
@@ -185,7 +185,7 @@ pub trait BufRead: crate::Io {
185
185
/// Blocking writer.
186
186
///
187
187
/// Semantics are the same as [`std::io::Write`], check its documentation for details.
188
- pub trait Write : crate :: Io {
188
+ pub trait Write : crate :: ErrorType {
189
189
/// Write a buffer into this writer, returning how many bytes were written.
190
190
fn write ( & mut self , buf : & [ u8 ] ) -> Result < usize , Self :: Error > ;
191
191
@@ -246,7 +246,7 @@ pub trait Write: crate::Io {
246
246
/// Blocking seek within streams.
247
247
///
248
248
/// Semantics are the same as [`std::io::Seek`], check its documentation for details.
249
- pub trait Seek : crate :: Io {
249
+ pub trait Seek : crate :: ErrorType {
250
250
/// Seek to an offset, in bytes, in a stream.
251
251
fn seek ( & mut self , pos : crate :: SeekFrom ) -> Result < u64 , Self :: Error > ;
252
252
@@ -266,7 +266,7 @@ pub trait Seek: crate::Io {
266
266
///
267
267
/// This allows using a [`Read`] or [`BufRead`] in a nonblocking fashion, i.e. trying to read
268
268
/// only when it is ready.
269
- pub trait ReadReady : crate :: Io {
269
+ pub trait ReadReady : crate :: ErrorType {
270
270
/// Get whether the reader is ready for immediately reading.
271
271
///
272
272
/// This usually means that there is either some bytes have been received and are buffered and ready to be read,
@@ -280,7 +280,7 @@ pub trait ReadReady: crate::Io {
280
280
///
281
281
/// This allows using a [`Write`] in a nonblocking fashion, i.e. trying to write
282
282
/// only when it is ready.
283
- pub trait WriteReady : crate :: Io {
283
+ pub trait WriteReady : crate :: ErrorType {
284
284
/// Get whether the writer is ready for immediately writing.
285
285
///
286
286
/// This usually means that there is free space in the internal transmit buffer.
0 commit comments