Skip to main content

ADBServerDevice

Struct ADBServerDevice 

Source
pub struct ADBServerDevice {
    pub identifier: Option<String>,
    pub transport_id: Option<u32>,
    /* private fields */
}
Expand description

Represents a device connected to the ADB server.

Fields§

§identifier: Option<String>

Unique device identifier.

§transport_id: Option<u32>

Optional transport id assigned by the ADB server.

When set, this takes precedence over identifier for transport selection. Required to disambiguate devices that report the same serial number.

Note: transport ids are volatile. They are reassigned by the ADB server on device reconnect or server restart, so callers must re-query devices_long each time rather than caching the id across operations.

Implementations§

Source§

impl ADBServerDevice

Source

pub fn new(identifier: String, server_addr: Option<SocketAddrV4>) -> Self

Instantiates a new ADBServerDevice, knowing its ADB identifier (as returned by adb devices command).

Source

pub fn new_with_transport_id( transport_id: u32, server_addr: Option<SocketAddrV4>, ) -> Self

Instantiates a new ADBServerDevice selected by its transport id (as returned by adb devices -l).

Use this when multiple devices share the same serial number, since transport id is always unique within a running ADB server. The id is volatile: do not cache it across device reconnects or server restarts — re-query via crate::server::ADBServer::devices_long.

Source

pub fn autodetect(server_addr: Option<SocketAddrV4>) -> Self

Instantiates a new ADBServerDevice, assuming only one is currently connected.

Source§

impl ADBServerDevice

Source

pub fn forward(&mut self, remote: String, local: String) -> Result<()>

Forward socket connection

Source

pub fn forward_remove(&mut self, local: String) -> Result<()>

Remove a previously applied forward rule by its local endpoint.

Source

pub fn forward_remove_all(&mut self) -> Result<()>

Remove all previously applied forward rules

Source§

impl ADBServerDevice

Source

pub fn host_features(&mut self) -> Result<Vec<HostFeatures>>

Lists available ADB server features.

Source§

impl ADBServerDevice

Source

pub fn install<P: AsRef<Path>>( &mut self, apk_path: P, user: Option<&str>, ) -> Result<()>

Install an APK on device

Source§

impl ADBServerDevice

Source

pub fn list<A: AsRef<str>>(&mut self, path: A) -> Result<Vec<ADBListItemType>>

Lists files in path on the device. note: path uses internal file paths, so Documents is at /storage/emulated/0/Documents

Source§

impl ADBServerDevice

Source

pub fn get_logs<W: Write>(&mut self, output: W) -> Result<()>

Get logs from device

Source§

impl ADBServerDevice

Source

pub fn reboot(&mut self, reboot_type: RebootType) -> Result<()>

Reboots the device

Source§

impl ADBServerDevice

Source

pub fn reconnect(&mut self) -> Result<()>

Reconnect device

Source§

impl ADBServerDevice

Source

pub fn pull( &mut self, path: &dyn AsRef<str>, stream: &mut dyn Write, ) -> Result<()>

Receives path to stream from the device.

Source§

impl ADBServerDevice

Source

pub fn remount(&mut self) -> Result<Vec<RemountInfo>>

Remounts the device filesystem as read-write

Source§

impl ADBServerDevice

Source

pub fn reverse(&mut self, remote: String, local: String) -> Result<()>

Reverse socket connection

Source

pub fn reverse_remove(&mut self, remote: String) -> Result<()>

Remove a previously applied reverse rule by its remote endpoint.

Source

pub fn reverse_remove_all(&mut self) -> Result<()>

Remove all reverse rules

Source§

impl ADBServerDevice

Source

pub fn root(&mut self) -> Result<()>

Restart adb daemon with root permissions

Source§

impl ADBServerDevice

Source

pub fn push<R: Read, A: AsRef<str>>(&mut self, stream: R, path: A) -> Result<()>

Send stream to path on the device.

Source§

impl ADBServerDevice

Source

pub fn stat<A: AsRef<str>>(&mut self, path: A) -> Result<AdbStatResponse>

Stat file given as path on the device.

Source§

impl ADBServerDevice

Source

pub fn tcpip(&mut self, port: u16) -> Result<()>

Set adb daemon to tcp/ip mode

Source§

impl ADBServerDevice

Source

pub fn transport_any(&mut self) -> Result<()>

Asks ADB server to switch the connection to either the device or emulator connect to/running on the host. Will fail if there is more than one such device/emulator available.

Source§

impl ADBServerDevice

Source

pub fn uninstall( &mut self, package_name: &str, user: Option<&str>, ) -> Result<()>

Uninstall a package from device

Source§

impl ADBServerDevice

Source

pub fn usb(&mut self) -> Result<()>

Set adb daemon to usb mode

Source§

impl ADBServerDevice

Source

pub fn disable_verity(&mut self) -> Result<()>

Disable verity on the device

Source

pub fn enable_verity(&mut self) -> Result<()>

Enable verity on the device

Trait Implementations§

Source§

impl ADBDeviceExt for ADBServerDevice

Source§

fn shell_command( &mut self, command: &dyn AsRef<str>, stdout: Option<&mut dyn Write>, stderr: Option<&mut dyn Write>, ) -> Result<Option<u8>>

Runs command in a shell on the device, and write its output and error streams into output.
Source§

fn stat(&mut self, remote_path: &dyn AsRef<str>) -> Result<AdbStatResponse>

Display the stat information for a remote file using STAT protocol command.
Source§

fn exec( &mut self, command: &str, reader: &mut dyn Read, writer: Box<dyn Write + Send>, ) -> Result<()>

Runs command on the device. Input data is read from reader and write to writer.
Source§

fn shell( &mut self, reader: &mut dyn Read, writer: Box<dyn Write + Send>, ) -> Result<()>

Starts an interactive shell session on the device. Input data is read from reader and write to writer.
Source§

fn pull( &mut self, source: &dyn AsRef<str>, output: &mut dyn Write, ) -> Result<()>

Pull the remote file pointed to by source and write its contents into output
Source§

fn reboot(&mut self, reboot_type: RebootType) -> Result<()>

Reboot the device using given reboot type
Source§

fn root(&mut self) -> Result<()>

Restart adb daemon with root permissions
Source§

fn push(&mut self, stream: &mut dyn Read, path: &dyn AsRef<str>) -> Result<()>

Push stream to path on the device.
Source§

fn install( &mut self, apk_path: &dyn AsRef<Path>, user: Option<&str>, ) -> Result<()>

Install an APK pointed to by apk_path on device.
Source§

fn uninstall( &mut self, package: &dyn AsRef<str>, user: Option<&str>, ) -> Result<()>

Uninstall the package package from device.
Source§

fn framebuffer_inner(&mut self) -> Result<ImageBuffer<Rgba<u8>, Vec<u8>>>

Available on crate feature framebuffer only.
Inner method requesting framebuffer from an Android device
Source§

fn list(&mut self, path: &dyn AsRef<str>) -> Result<Vec<ADBListItemType>>

List the items in a directory on the device
Source§

fn remount(&mut self) -> Result<Vec<RemountInfo>>

Remount the device partitions as read-write
Source§

fn enable_verity(&mut self) -> Result<()>

Enable dm-verity on the device
Source§

fn disable_verity(&mut self) -> Result<()>

Disable dm-verity on the device
Source§

fn stat_extended( &mut self, remote_path: &dyn AsRef<str>, ) -> Result<Option<ADBStatExtendedResponse>>

Display the stat information for a remote file using stat shell command. This is an extended version of stat that returns more detailed information. Returns Ok(None) if the file does not exist on the device.
Source§

fn run_activity( &mut self, package: &dyn AsRef<str>, activity: &dyn AsRef<str>, ) -> Result<Vec<u8>>

Run activity from package on device. Return the command output.
Source§

fn framebuffer(&mut self, path: &dyn AsRef<Path>) -> Result<()>

Available on crate feature framebuffer only.
Dump framebuffer of this device into given path. Read more
Source§

fn framebuffer_bytes(&mut self) -> Result<Vec<u8>>

Available on crate feature framebuffer only.
Dump framebuffer of this device and return corresponding bytes. Read more
Source§

fn boxed(self) -> Box<dyn ADBDeviceExt>
where Self: Sized + 'static,

Return a boxed instance representing this trait
Source§

impl Debug for ADBServerDevice

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for ADBServerDevice

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl TryFrom<ADBServerDevice> for ADBEmulatorDevice

Source§

type Error = RustADBError

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

fn try_from(value: ADBServerDevice) -> Result<Self, Self::Error>

Performs the conversion.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V