mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-26 00:32:33 +00:00
sync/pipe: write all user data to pipe
sync/pipe: add write_all function
This commit is contained in:
parent
f2c2536cf3
commit
24c4ea71b1
@ -294,6 +294,16 @@ where
|
||||
WriteFuture { pipe: self, buf }
|
||||
}
|
||||
|
||||
/// Write all bytes to the pipe.
|
||||
///
|
||||
/// This method writes all bytes from `buf` into the pipe
|
||||
pub async fn write_all(&self, mut buf: &[u8]) {
|
||||
while !buf.is_empty() {
|
||||
let n = self.write(buf).await;
|
||||
buf = &buf[n..];
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempt to immediately write some bytes to the pipe.
|
||||
///
|
||||
/// This method will either write a nonzero amount of bytes to the pipe immediately,
|
||||
|
Loading…
Reference in New Issue
Block a user