pub struct BlockWriter<'a> { /* private fields */ }Expand description
Splits a byte buffer into sub-block segments — used by the download client and the upload server.
Pull BlockWriter::next_segment until it yields None; if
BlockWriter::is_done then send the BlockWriter::end_frame, otherwise
transmit the sub-block, await the acknowledgement, call
BlockWriter::start_sub_block with the next blksize, and repeat.
Implementations§
Source§impl<'a> BlockWriter<'a>
impl<'a> BlockWriter<'a>
Sourcepub fn new(data: &'a [u8], blksize: u8) -> Self
pub fn new(data: &'a [u8], blksize: u8) -> Self
Start splitting data using the negotiated first blksize.
Sourcepub const fn is_done(&self) -> bool
pub const fn is_done(&self) -> bool
Whether every byte has been emitted (then send Self::end_frame).
Sourcepub fn next_segment(&mut self) -> Option<SdoPayload>
pub fn next_segment(&mut self) -> Option<SdoPayload>
The next segment of the current sub-block, or None when the sub-block
is full or the data is exhausted (disambiguate with Self::is_done).
Sourcepub fn start_sub_block(&mut self, blksize: u8)
pub fn start_sub_block(&mut self, blksize: u8)
Begin the next sub-block after an acknowledgement, using blksize.
Sourcepub fn end_frame(&self, crc_support: bool) -> SdoPayload
pub fn end_frame(&self, crc_support: bool) -> SdoPayload
The end frame: the CRC over all data (when crc_support) and the count
of unused bytes in the last segment.