pub struct BdxWriter<'a, 'b> { /* private fields */ }Expand description
A writer over a BDX transfer - the Sender side.
Obtained from Exchange::upload on the initiating side, or
from BdxDownloadResponder::reply on the responding side. write
stages and sends the data, driving the protocol as needed;
finish flushes the final block and completes the transfer.
It also implements embedded_io_async::Write (delegating to the inherent
write).
The caller supplies the staging buffer buf, which doubles as the upper bound
on the block size (so there is no hidden, MCU-unfriendly internal allocation).
It must be non-empty.
Implementations§
Source§impl<'a, 'b> BdxWriter<'a, 'b>
impl<'a, 'b> BdxWriter<'a, 'b>
Sourcepub async fn write(&mut self, data: &[u8]) -> Result<usize, Error>
pub async fn write(&mut self, data: &[u8]) -> Result<usize, Error>
Stage and send data, returning the number of bytes accepted (< data.len()
only when the current block fills; call again with the remainder).
This is also the embedded_io_async::Write implementation; the inherent
method is kept so callers need not import the trait.
Sourcepub fn max_block_size(&self) -> usize
pub fn max_block_size(&self) -> usize
The largest block this writer will send (and the length of the buffer
returned by block_buf).
Sourcepub fn block_buf(&mut self) -> &mut [u8] ⓘ
pub fn block_buf(&mut self) -> &mut [u8] ⓘ
The writer’s own staging buffer (exactly max_block_size
bytes), to be filled in place and then sent with commit.
This is the zero-extra-buffer alternative to write: a
caller streaming from another source (a flash region, a socket) can read
straight into this slice instead of into its own buffer and copying. Do not
interleave it with write, which stages into the same space.
Trait Implementations§
Source§impl Write for BdxWriter<'_, '_>
impl Write for BdxWriter<'_, '_>
Source§async fn flush(&mut self) -> Result<(), <BdxWriter<'_, '_> as ErrorType>::Error>
async fn flush(&mut self) -> Result<(), <BdxWriter<'_, '_> as ErrorType>::Error>
Send any staged-but-unsent bytes as a (non-final) block.
Auto Trait Implementations§
impl<'a, 'b> !RefUnwindSafe for BdxWriter<'a, 'b>
impl<'a, 'b> !Send for BdxWriter<'a, 'b>
impl<'a, 'b> !Sync for BdxWriter<'a, 'b>
impl<'a, 'b> !UnwindSafe for BdxWriter<'a, 'b>
impl<'a, 'b> Freeze for BdxWriter<'a, 'b>
impl<'a, 'b> Unpin for BdxWriter<'a, 'b>
impl<'a, 'b> UnsafeUnpin for BdxWriter<'a, 'b>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more