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
impl ADBServerDevice
Sourcepub fn new(identifier: String, server_addr: Option<SocketAddrV4>) -> Self
pub fn new(identifier: String, server_addr: Option<SocketAddrV4>) -> Self
Instantiates a new ADBServerDevice, knowing its ADB identifier (as returned by adb devices command).
Sourcepub fn new_with_transport_id(
transport_id: u32,
server_addr: Option<SocketAddrV4>,
) -> Self
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.
Sourcepub fn autodetect(server_addr: Option<SocketAddrV4>) -> Self
pub fn autodetect(server_addr: Option<SocketAddrV4>) -> Self
Instantiates a new ADBServerDevice, assuming only one is currently connected.
Source§impl ADBServerDevice
impl ADBServerDevice
Sourcepub fn forward(&mut self, remote: String, local: String) -> Result<()>
pub fn forward(&mut self, remote: String, local: String) -> Result<()>
Forward socket connection
Sourcepub fn forward_remove(&mut self, local: String) -> Result<()>
pub fn forward_remove(&mut self, local: String) -> Result<()>
Remove a previously applied forward rule by its local endpoint.
Sourcepub fn forward_remove_all(&mut self) -> Result<()>
pub fn forward_remove_all(&mut self) -> Result<()>
Remove all previously applied forward rules
Source§impl ADBServerDevice
impl ADBServerDevice
Sourcepub fn host_features(&mut self) -> Result<Vec<HostFeatures>>
pub fn host_features(&mut self) -> Result<Vec<HostFeatures>>
Lists available ADB server features.
Source§impl ADBServerDevice
impl ADBServerDevice
Sourcepub fn reboot(&mut self, reboot_type: RebootType) -> Result<()>
pub fn reboot(&mut self, reboot_type: RebootType) -> Result<()>
Reboots the device
Source§impl ADBServerDevice
impl ADBServerDevice
Sourcepub fn remount(&mut self) -> Result<Vec<RemountInfo>>
pub fn remount(&mut self) -> Result<Vec<RemountInfo>>
Remounts the device filesystem as read-write
Source§impl ADBServerDevice
impl ADBServerDevice
Sourcepub fn reverse(&mut self, remote: String, local: String) -> Result<()>
pub fn reverse(&mut self, remote: String, local: String) -> Result<()>
Reverse socket connection
Sourcepub fn reverse_remove(&mut self, remote: String) -> Result<()>
pub fn reverse_remove(&mut self, remote: String) -> Result<()>
Remove a previously applied reverse rule by its remote endpoint.
Sourcepub fn reverse_remove_all(&mut self) -> Result<()>
pub fn reverse_remove_all(&mut self) -> Result<()>
Remove all reverse rules
Source§impl ADBServerDevice
impl ADBServerDevice
Sourcepub fn transport_any(&mut self) -> Result<()>
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
impl ADBServerDevice
Sourcepub fn disable_verity(&mut self) -> Result<()>
pub fn disable_verity(&mut self) -> Result<()>
Disable verity on the device
Sourcepub fn enable_verity(&mut self) -> Result<()>
pub fn enable_verity(&mut self) -> Result<()>
Enable verity on the device
Trait Implementations§
Source§impl ADBDeviceExt for ADBServerDevice
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>>
fn shell_command( &mut self, command: &dyn AsRef<str>, stdout: Option<&mut dyn Write>, stderr: Option<&mut dyn Write>, ) -> Result<Option<u8>>
Source§fn stat(&mut self, remote_path: &dyn AsRef<str>) -> Result<AdbStatResponse>
fn stat(&mut self, remote_path: &dyn AsRef<str>) -> Result<AdbStatResponse>
Source§fn exec(
&mut self,
command: &str,
reader: &mut dyn Read,
writer: Box<dyn Write + Send>,
) -> Result<()>
fn exec( &mut self, command: &str, reader: &mut dyn Read, writer: Box<dyn Write + Send>, ) -> Result<()>
Source§fn shell(
&mut self,
reader: &mut dyn Read,
writer: Box<dyn Write + Send>,
) -> Result<()>
fn shell( &mut self, reader: &mut dyn Read, writer: Box<dyn Write + Send>, ) -> Result<()>
Source§fn pull(
&mut self,
source: &dyn AsRef<str>,
output: &mut dyn Write,
) -> Result<()>
fn pull( &mut self, source: &dyn AsRef<str>, output: &mut dyn Write, ) -> Result<()>
source and write its contents into outputSource§fn reboot(&mut self, reboot_type: RebootType) -> Result<()>
fn reboot(&mut self, reboot_type: RebootType) -> Result<()>
Source§fn push(&mut self, stream: &mut dyn Read, path: &dyn AsRef<str>) -> Result<()>
fn push(&mut self, stream: &mut dyn Read, path: &dyn AsRef<str>) -> Result<()>
stream to path on the device.Source§fn install(
&mut self,
apk_path: &dyn AsRef<Path>,
user: Option<&str>,
) -> Result<()>
fn install( &mut self, apk_path: &dyn AsRef<Path>, user: Option<&str>, ) -> Result<()>
apk_path on device.Source§fn uninstall(
&mut self,
package: &dyn AsRef<str>,
user: Option<&str>,
) -> Result<()>
fn uninstall( &mut self, package: &dyn AsRef<str>, user: Option<&str>, ) -> Result<()>
package from device.Source§fn framebuffer_inner(&mut self) -> Result<ImageBuffer<Rgba<u8>, Vec<u8>>>
fn framebuffer_inner(&mut self) -> Result<ImageBuffer<Rgba<u8>, Vec<u8>>>
framebuffer only.Source§fn list(&mut self, path: &dyn AsRef<str>) -> Result<Vec<ADBListItemType>>
fn list(&mut self, path: &dyn AsRef<str>) -> Result<Vec<ADBListItemType>>
Source§fn enable_verity(&mut self) -> Result<()>
fn enable_verity(&mut self) -> Result<()>
Source§fn disable_verity(&mut self) -> Result<()>
fn disable_verity(&mut self) -> Result<()>
Source§fn stat_extended(
&mut self,
remote_path: &dyn AsRef<str>,
) -> Result<Option<ADBStatExtendedResponse>>
fn stat_extended( &mut self, remote_path: &dyn AsRef<str>, ) -> Result<Option<ADBStatExtendedResponse>>
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>>
fn run_activity( &mut self, package: &dyn AsRef<str>, activity: &dyn AsRef<str>, ) -> Result<Vec<u8>>
activity from package on device. Return the command output.Source§fn framebuffer(&mut self, path: &dyn AsRef<Path>) -> Result<()>
fn framebuffer(&mut self, path: &dyn AsRef<Path>) -> Result<()>
framebuffer only.