diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-06-05 02:48:36 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-05 02:48:36 +0200 |
| commit | d690a1717fd03a1f3fdad509d6a638567f8a645a (patch) | |
| tree | fc053d790e893ee5982cd39bc30d3046e445dbda | |
| parent | f6d75970d8beddc08f0f233fdee9d51a5264bd67 (diff) | |
| parent | 24c4ea71b11ce6c07d92dd6876fec6a9b0f6ed10 (diff) | |
Merge pull request #1530 from cumthugo/write_func_in_pipe
sync/pipe: write all user data to pipe
| -rw-r--r-- | embassy-sync/src/pipe.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index ee27cdec8..db6ebb08b 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs | |||
| @@ -294,6 +294,16 @@ where | |||
| 294 | WriteFuture { pipe: self, buf } | 294 | WriteFuture { pipe: self, buf } |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | /// Write all bytes to the pipe. | ||
| 298 | /// | ||
| 299 | /// This method writes all bytes from `buf` into the pipe | ||
| 300 | pub async fn write_all(&self, mut buf: &[u8]) { | ||
| 301 | while !buf.is_empty() { | ||
| 302 | let n = self.write(buf).await; | ||
| 303 | buf = &buf[n..]; | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 297 | /// Attempt to immediately write some bytes to the pipe. | 307 | /// Attempt to immediately write some bytes to the pipe. |
| 298 | /// | 308 | /// |
| 299 | /// This method will either write a nonzero amount of bytes to the pipe immediately, | 309 | /// This method will either write a nonzero amount of bytes to the pipe immediately, |
