Skip to main content

DfuAsync

Struct DfuAsync 

Source
pub struct DfuAsync<IO, E>
where IO: DfuAsyncIo<Read = usize, Write = usize, Reset = (), Error = E>, E: From<Error> + From<Error>,
{ /* private fields */ }
Available on crate features async and std only.
Expand description

Generic asynchronous implementation of DFU.

Implementations§

Source§

impl<IO, E> DfuAsync<IO, E>
where IO: DfuAsyncIo<Read = usize, Write = usize, Reset = (), Error = E>, E: From<Error> + From<Error>,

Source

pub fn new(io: IO) -> Self

Create a new instance of a generic synchronous implementation of DFU.

Source

pub fn override_address(&mut self, address: u32) -> &mut Self

Override the address onto which the firmware is downloaded.

This address is only used if the device uses the DfuSe protocol.

Source

pub fn into_inner(self) -> IO

Consume the object and return its DfuIo

Source§

impl<IO, E> DfuAsync<IO, E>
where IO: DfuAsyncIo<Read = usize, Write = usize, Reset = (), Error = E>, E: From<Error> + From<Error>,

Source

pub async fn download_from_slice( self, slice: &[u8], ) -> Result<Option<Self>, IO::Error>

Download a firmware into the device from a slice.

Returns Some(Self) if the device stayed on the bus (manifestation tolerant, no USB reset occurred) or None if a USB reset was performed.

Source

pub async fn download<R: AsyncReadExt + Unpin>( self, reader: R, length: u32, ) -> Result<Option<Self>, IO::Error>

Download a firmware into the device from a reader.

Returns Some(Self) if the device stayed on the bus (manifestation tolerant, no USB reset occurred) or None if a USB reset was performed.

Source

pub async fn download_all<R: AsyncReadExt + Unpin + AsyncSeek>( self, reader: R, ) -> Result<Option<Self>, IO::Error>

Download a firmware into the device.

The length is inferred from the reader. Returns Some(Self) if the device stayed on the bus (manifestation tolerant, no USB reset occurred) or None if a USB reset was performed.

Source

pub async fn detach(&self) -> Result<(), IO::Error>

Send a Detach request to the device

Source

pub async fn usb_reset(self) -> Result<IO::Reset, IO::Error>

Reset the USB device

Source

pub fn will_detach(&self) -> bool

Returns whether the device will detach if requested

Source

pub fn manifestation_tolerant(&self) -> bool

Returns whether the device is manifestation tolerant

Auto Trait Implementations§

§

impl<IO, E> Freeze for DfuAsync<IO, E>
where IO: Freeze,

§

impl<IO, E> RefUnwindSafe for DfuAsync<IO, E>
where IO: RefUnwindSafe,

§

impl<IO, E> Send for DfuAsync<IO, E>
where IO: Send,

§

impl<IO, E> Sync for DfuAsync<IO, E>
where IO: Sync,

§

impl<IO, E> Unpin for DfuAsync<IO, E>
where IO: Unpin,

§

impl<IO, E> UnsafeUnpin for DfuAsync<IO, E>
where IO: UnsafeUnpin,

§

impl<IO, E> UnwindSafe for DfuAsync<IO, E>
where IO: UnwindSafe,

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.