XmodemOneKPacket

Struct XmodemOneKPacket 

Source
pub struct XmodemOneKPacket { /* private fields */ }
Expand description

Represents an XMODEM-1K (compatible) packet.

Implementations§

Source§

impl XmodemOneKPacket

Source

pub const LEN: usize = 1_029usize

Represents the full byte length of an XmodemOneKPacket.

Source

pub const fn new() -> Self

Creates a new XmodemOneKPacket.

Source

pub const fn start(&self) -> Control

Gets the start Control byte.

Source

pub const fn sequence(&self) -> Sequence

Gets the Sequence number.

Source

pub fn set_sequence(&mut self, seq: Sequence)

Sets the Sequence, and complement Sequence numbers.

Source

pub const fn with_sequence(self, seq: Sequence) -> Self

Builder function that sets the Sequence, and complement Sequence numbers.

Source

pub const fn complement_sequence(&self) -> Sequence

Gets the complement Sequence number.

Source

pub const fn data(&self) -> &OneKData

Gets a reference to the OneKData.

Source

pub fn set_data(&mut self, data: OneKData)

Sets the OneKData, and calculates the Checksum.

Source

pub const fn with_data(self, data: OneKData) -> Self

Builder function that sets the OneKData, and calculates the Checksum.

Source

pub const fn checksum(&self) -> Crc16

Gets the Checksum.

Source

pub const fn validate(self) -> Result<Self>

Validates the invariants of the XmodemOneKPacket format.

Consumes and returns the XmodemOneKPacket, if valid.

Returns Error otherwise.

Source

pub fn into_bytes(self) -> [u8; 1029]

Infallible conversion from XmodemOneKPacket into bytes.

NOTE: does not validate XmodemOneKPacket before conversion. For the validating version, use XmodemOneKPacket::try_into.

Trait Implementations§

Source§

impl Clone for XmodemOneKPacket

Source§

fn clone(&self) -> XmodemOneKPacket

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for XmodemOneKPacket

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for XmodemOneKPacket

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl IntoIterator for XmodemOneKPacket

Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = Chain<Chain<IntoIter<u8, { XmodemOneKPacket::PRELUDE_LEN }>, IntoIter<u8, { OneKData::LEN }>>, IntoIter<u8, { Crc16::LEN }>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for XmodemOneKPacket

Source§

fn eq(&self, other: &XmodemOneKPacket) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&[u8]> for XmodemOneKPacket

Source§

type Error = Error

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

fn try_from(val: &[u8]) -> Result<Self>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<&[u8; N]> for XmodemOneKPacket

Source§

type Error = Error

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

fn try_from(val: &[u8; N]) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&XmodemOneKPacket> for [u8; 1029]

Source§

type Error = Error

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

fn try_from(val: &XmodemOneKPacket) -> Result<Self>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<[u8; N]> for XmodemOneKPacket

Source§

type Error = Error

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

fn try_from(val: [u8; N]) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<XmodemOneKPacket> for [u8; 1029]

Source§

type Error = Error

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

fn try_from(val: XmodemOneKPacket) -> Result<Self>

Performs the conversion.
Source§

impl Copy for XmodemOneKPacket

Source§

impl Eq for XmodemOneKPacket

Source§

impl StructuralPartialEq for XmodemOneKPacket

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.