Skip to main content

VirtualDeviceConfig

Struct VirtualDeviceConfig 

Source
pub struct VirtualDeviceConfig {
    pub manufacturer: String,
    pub model: String,
    pub serial: String,
    pub storages: Vec<VirtualStorageConfig>,
    pub supports_rename: bool,
    pub event_poll_interval: Duration,
    pub watch_backing_dirs: bool,
}
Expand description

Configuration for a virtual MTP device.

Defines the identity and storages of a virtual device that operates against a local filesystem directory instead of real USB hardware.

§Example

use std::path::PathBuf;
use std::time::Duration;
use mtp_rs::transport::virtual_device::config::{VirtualDeviceConfig, VirtualStorageConfig};

let config = VirtualDeviceConfig {
    manufacturer: "Google".into(),
    model: "Virtual Pixel 9".into(),
    serial: "virtual-001".into(),
    storages: vec![VirtualStorageConfig {
        description: "Internal Storage".into(),
        capacity: 64 * 1024 * 1024 * 1024,
        backing_dir: PathBuf::from("/tmp/mtp-test"),
        read_only: false,
    }],
    supports_rename: true,
    event_poll_interval: Duration::from_millis(50),
    watch_backing_dirs: true,
};

Fields§

§manufacturer: String

Manufacturer name reported by the virtual device.

§model: String

Model name reported by the virtual device.

§serial: String

Serial number for the virtual device.

§storages: Vec<VirtualStorageConfig>

Storage configurations. At least one storage is required.

§supports_rename: bool

Whether the device advertises SetObjectPropValue support (rename).

§event_poll_interval: Duration

How long receive_interrupt waits when no events are pending. Simulates the USB interrupt endpoint blocking behavior. Default: 50ms for production use. Use Duration::ZERO in tests to avoid slowing down the test suite.

§watch_backing_dirs: bool

Watch backing directories for out-of-band changes and emit MTP events. When true, a background filesystem watcher detects files created or removed directly in the backing directories (bypassing MTP) and queues ObjectAdded/ObjectRemoved events. Set to false for tests that don’t need this (faster startup, no background threads).

Trait Implementations§

Source§

impl Clone for VirtualDeviceConfig

Source§

fn clone(&self) -> VirtualDeviceConfig

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 VirtualDeviceConfig

Source§

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

Formats the value using the given formatter. Read more

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.