Skip to main content

PtpDevice

Struct PtpDevice 

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

A low-level PTP device connection.

Use this for camera support or when you need raw PTP operations. For typical MTP usage with Android devices, prefer MtpDevice instead.

Implementations§

Source§

impl PtpDevice

Source

pub async fn open_by_location(location_id: u64) -> Result<Self, Error>

Open a PTP device at a specific USB location (port).

Source

pub async fn open_by_location_with_timeout( location_id: u64, timeout: Duration, ) -> Result<Self, Error>

Open by location with custom timeout.

Source

pub async fn open_by_serial(serial: &str) -> Result<Self, Error>

Open a PTP device by its serial number.

Source

pub async fn open_by_serial_with_timeout( serial: &str, timeout: Duration, ) -> Result<Self, Error>

Open by serial with custom timeout.

Source

pub async fn open_first() -> Result<Self, Error>

Open the first available PTP device.

Source

pub async fn open_first_with_timeout(timeout: Duration) -> Result<Self, Error>

Open the first available device with custom timeout.

Source

pub async fn get_device_info(&self) -> Result<DeviceInfo, Error>

Get device info without opening a session.

This is the only operation that can be performed without a session.

Source

pub async fn open_session(&self) -> Result<PtpSession, Error>

Open a PTP session.

Most operations require a session to be open first.

Source

pub async fn open_session_with_id( &self, session_id: u32, ) -> Result<PtpSession, Error>

Open a session with a specific session ID.

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