State

Struct State 

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

Send or receive transmission state

Implementations§

Source§

impl State

Source

pub const fn new() -> Self

Create a new transmission context

Source

pub fn set_first_file(file_name: &str, file_size: u32) -> Result<Self, Error>

Create a new transmission context for the first file in a batch.

§Errors
  • Read when the read I/O fails with the serial port
  • Write when the write I/O fails with the serial port
  • Data when corrupted data has been detected
Source

pub fn set_next_file( &mut self, file_name: &str, file_size: u32, ) -> Result<(), Error>

Prepares the state for the next file in a batch transfer.

§Errors
  • Data when the file_name is invalid.
Source

pub fn stage(&self) -> Stage

Source

pub fn count(&self) -> u32

Source

pub fn file_name(&self) -> &[u8]

Source

pub fn file_size(&self) -> u32

Source

pub fn send<P, F>( &mut self, port: &mut P, file: &mut F, ) -> Result<Option<()>, Error>
where P: Read + Write + ?Sized, F: Read + Seek + ?Sized,

Sends a file using the ZMODEM file transfer protocol.

§Errors
  • Read when the read I/O fails with the serial port
  • Write when the write I/O fails with the serial port
  • Data when corrupted data has been detected
Source

pub fn receive<P, F>( &mut self, port: &mut P, file: &mut F, ) -> Result<Option<()>, Error>
where P: Read + Write + ?Sized, F: Write + ?Sized,

Receives a file using the ZMODEM file transfer protocol.

§Errors
  • Read when the read I/O fails with the serial port
  • Write when the write I/O fails with the serial port
  • Data when corrupted data has been detected
Source

pub fn finish<P>(&mut self, port: &mut P) -> Result<Option<()>, Error>
where P: Read + Write + ?Sized,

Send ZFIN.

§Errors
  • Read when the read I/O fails with the serial port
  • Write when the write I/O fails with the serial port
  • Data when corrupted data has been detected

Trait Implementations§

Source§

impl Default for State

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for State

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnwindSafe for State

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.