Fixes doc tests + bump dependencies
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "adb_client"
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
description = "Rust ADB (Android Debug Bridge) client library"
|
||||
keywords = ["adb", "android"]
|
||||
readme = "README.md"
|
||||
@@ -19,7 +19,7 @@ path = "bin/adb_client.rs"
|
||||
required-features = ["adbclient"]
|
||||
|
||||
[dependencies]
|
||||
thiserror = { version = "1.0.30", default_features = false }
|
||||
thiserror = { version = "1.0.31", default_features = false }
|
||||
regex = { version = "1.5.5", default_features = false, features = ["std", "perf", "unicode"] }
|
||||
termios = { version = "0.3.3", default_features = false }
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ To launch a command on host device :
|
||||
use adb_client::AdbTcpConnexion;
|
||||
|
||||
let connexion = AdbTcpConnexion::new();
|
||||
connexion.shell_command("df -h");
|
||||
connexion.shell_command(None, vec!["df", "-h"]);
|
||||
```
|
||||
|
||||
To get available ADB devices :
|
||||
|
||||
@@ -192,15 +192,25 @@ impl AdbTcpConnexion {
|
||||
}
|
||||
|
||||
/// Runs 'command' in a shell on the device, and return its output and error streams.
|
||||
pub fn shell_command(&self, serial: Option<String>, command: Vec<String>) -> Result<()> {
|
||||
pub fn shell_command<S: ToString>(&self, serial: Option<S>, command: Vec<S>) -> Result<()> {
|
||||
let mut tcp_stream = TcpStream::connect(self.socket_addr)?;
|
||||
match serial {
|
||||
None => Self::send_adb_request(&mut tcp_stream, AdbCommand::TransportAny)?,
|
||||
Some(serial) => {
|
||||
Self::send_adb_request(&mut tcp_stream, AdbCommand::TransportSerial(serial))?
|
||||
}
|
||||
Some(serial) => Self::send_adb_request(
|
||||
&mut tcp_stream,
|
||||
AdbCommand::TransportSerial(serial.to_string()),
|
||||
)?,
|
||||
}
|
||||
Self::send_adb_request(&mut tcp_stream, AdbCommand::ShellCommand(command.join(" ")))?;
|
||||
Self::send_adb_request(
|
||||
&mut tcp_stream,
|
||||
AdbCommand::ShellCommand(
|
||||
command
|
||||
.iter()
|
||||
.map(|v| v.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(" "),
|
||||
),
|
||||
)?;
|
||||
|
||||
let buffer_size = 512;
|
||||
loop {
|
||||
@@ -222,7 +232,7 @@ impl AdbTcpConnexion {
|
||||
}
|
||||
|
||||
/// Starts an interactive shell session on the device. Redirects stdin/stdout/stderr as appropriate.
|
||||
pub fn shell(&self, serial: Option<String>) -> Result<()> {
|
||||
pub fn shell<S: ToString>(&self, serial: Option<S>) -> Result<()> {
|
||||
let mut adb_termios = ADBTermios::new(std::io::stdin())?;
|
||||
adb_termios.set_adb_termios()?;
|
||||
|
||||
@@ -232,7 +242,7 @@ impl AdbTcpConnexion {
|
||||
match serial {
|
||||
None => Self::send_adb_request(&mut tcp_stream, AdbCommand::TransportAny)?,
|
||||
Some(serial) => {
|
||||
Self::send_adb_request(&mut tcp_stream, AdbCommand::TransportSerial(serial))?
|
||||
Self::send_adb_request(&mut tcp_stream, AdbCommand::TransportSerial(serial.to_string()))?
|
||||
}
|
||||
}
|
||||
Self::send_adb_request(&mut tcp_stream, AdbCommand::Shell)?;
|
||||
|
||||
Reference in New Issue
Block a user