File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ impl Socket {
44
44
op. await
45
45
}
46
46
47
+ pub async fn writev < T : IoBuf > ( & self , buf : Vec < T > ) -> crate :: BufResult < usize , Vec < T > > {
48
+ let op = Op :: writev_at ( & self . fd , buf, 0 ) . unwrap ( ) ;
49
+ op. await
50
+ }
51
+
47
52
pub ( crate ) async fn send_to < T : IoBuf > (
48
53
& self ,
49
54
buf : T ,
Original file line number Diff line number Diff line change @@ -164,6 +164,34 @@ impl TcpStream {
164
164
( Ok ( ( ) ) , buf)
165
165
}
166
166
167
+ /// Write data from buffers into this socket returning how many bytes were
168
+ /// written.
169
+ ///
170
+ /// This function will attempt to write the entire contents of `bufs`, but
171
+ /// the entire write may not succeed, or the write may also generate an
172
+ /// error. The bytes will be written starting at the specified offset.
173
+ ///
174
+ /// # Return
175
+ ///
176
+ /// The method returns the operation result and the same array of buffers
177
+ /// passed in as an argument. A return value of `0` typically means that the
178
+ /// underlying socket is no longer able to accept bytes and will likely not
179
+ /// be able to in the future as well, or that the buffer provided is empty.
180
+ ///
181
+ /// # Errors
182
+ ///
183
+ /// Each call to `write` may generate an I/O error indicating that the
184
+ /// operation could not be completed. If an error is returned then no bytes
185
+ /// in the buffer were written to this writer.
186
+ ///
187
+ /// It is **not** considered an error if the entire buffer could not be
188
+ /// written to this writer.
189
+ ///
190
+ /// [`Ok(n)`]: Ok
191
+ pub async fn writev < T : IoBuf > ( & self , buf : Vec < T > ) -> crate :: BufResult < usize , Vec < T > > {
192
+ self . inner . writev ( buf) . await
193
+ }
194
+
167
195
/// Shuts down the read, write, or both halves of this connection.
168
196
///
169
197
/// This function will cause all pending and future I/O on the specified portions to return
Original file line number Diff line number Diff line change @@ -130,6 +130,34 @@ impl UnixStream {
130
130
( Ok ( ( ) ) , buf)
131
131
}
132
132
133
+ /// Write data from buffers into this socket returning how many bytes were
134
+ /// written.
135
+ ///
136
+ /// This function will attempt to write the entire contents of `bufs`, but
137
+ /// the entire write may not succeed, or the write may also generate an
138
+ /// error. The bytes will be written starting at the specified offset.
139
+ ///
140
+ /// # Return
141
+ ///
142
+ /// The method returns the operation result and the same array of buffers
143
+ /// passed in as an argument. A return value of `0` typically means that the
144
+ /// underlying socket is no longer able to accept bytes and will likely not
145
+ /// be able to in the future as well, or that the buffer provided is empty.
146
+ ///
147
+ /// # Errors
148
+ ///
149
+ /// Each call to `write` may generate an I/O error indicating that the
150
+ /// operation could not be completed. If an error is returned then no bytes
151
+ /// in the buffer were written to this writer.
152
+ ///
153
+ /// It is **not** considered an error if the entire buffer could not be
154
+ /// written to this writer.
155
+ ///
156
+ /// [`Ok(n)`]: Ok
157
+ pub async fn writev < T : IoBuf > ( & self , buf : Vec < T > ) -> crate :: BufResult < usize , Vec < T > > {
158
+ self . inner . writev ( buf) . await
159
+ }
160
+
133
161
/// Shuts down the read, write, or both halves of this connection.
134
162
///
135
163
/// This function will cause all pending and future I/O on the specified portions to return
You can’t perform that action at this time.
0 commit comments