Skip to main content

BlockWriter

Struct BlockWriter 

Source
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>

Source

pub fn new(data: &'a [u8], blksize: u8) -> Self

Start splitting data using the negotiated first blksize.

Source

pub const fn is_done(&self) -> bool

Whether every byte has been emitted (then send Self::end_frame).

Source

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).

Source

pub fn start_sub_block(&mut self, blksize: u8)

Begin the next sub-block after an acknowledgement, using blksize.

Source

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.

Trait Implementations§

Source§

impl<'a> Debug for BlockWriter<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BlockWriter<'a>

§

impl<'a> RefUnwindSafe for BlockWriter<'a>

§

impl<'a> Send for BlockWriter<'a>

§

impl<'a> Sync for BlockWriter<'a>

§

impl<'a> Unpin for BlockWriter<'a>

§

impl<'a> UnsafeUnpin for BlockWriter<'a>

§

impl<'a> UnwindSafe for BlockWriter<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.