embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

MtpReader

Struct MtpReader 

Source
pub struct MtpReader<'a> { /* private fields */ }
Expand description

Cursor-based deserializer for little-endian MTP/PTP datasets and UTF-16LE strings.

Implementations§

Source§

impl<'a> MtpReader<'a>

Source

pub const fn new(buf: &'a [u8]) -> Self

Creates a new MtpReader over buf.

Source

pub const fn remaining(&self) -> usize

Returns the number of unread bytes remaining.

Source

pub fn read_bytes(&mut self, len: usize) -> Result<&'a [u8], MtpError>

Reads an exact slice of len bytes.

Source

pub fn read_u8(&mut self) -> Result<u8, MtpError>

Reads a u8.

Source

pub fn read_u16(&mut self) -> Result<u16, MtpError>

Reads a little-endian u16.

Source

pub fn read_u32(&mut self) -> Result<u32, MtpError>

Reads a little-endian u32.

Source

pub fn read_u64(&mut self) -> Result<u64, MtpError>

Reads a little-endian u64.

Source

pub fn skip_string(&mut self) -> Result<(), MtpError>

Skips a PTP/MTP string without decoding its contents.

Source

pub fn read_string_utf8<'b>( &mut self, out: &'b mut [u8], ) -> Result<&'b str, MtpError>

Reads a PTP/MTP UTF-16LE string and encodes it as UTF-8 into out.

Auto Trait Implementations§

§

impl<'a> Forget for MtpReader<'a>

§

impl<'a> Freeze for MtpReader<'a>

§

impl<'a> Move for MtpReader<'a>

§

impl<'a> RefUnwindSafe for MtpReader<'a>

§

impl<'a> Send for MtpReader<'a>

§

impl<'a> Sync for MtpReader<'a>

§

impl<'a> Unpin for MtpReader<'a>

§

impl<'a> UnsafeUnpin for MtpReader<'a>

§

impl<'a> UnwindSafe for MtpReader<'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 = !

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

fn try_from(value: U) -> Result<T, !>

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.