Crates.io | adb-rust |
lib.rs | adb-rust |
version | |
source | src |
created_at | 2024-04-02 09:04:46.24494 |
updated_at | 2025-01-06 08:33:25.662481 |
description | A common adb operation |
homepage | |
repository | |
max_upload_size | |
id | 1193353 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
===========================
ADBCmd can execute commands synchronously or asynchronously using callback function closures.
Currently, this library is primarily used for invoking "cmd" commands in Rust, providing a variety of practical APIs.
Command
instance based on tokio::process::Command
, returning the instance of Command
.Command
output in real-time.std::process::Command
) to obtain the output of the current synchronous command, returning a Result<String, String>
.Result<String, String>
.[dependencies]
tokio = { version = "1.0", features = ["full"] }
adb-rust="0.2.1"
use adb_rust::cmd::{ADBCmd, ADBCmdResult};
pub fn push_xml_file() {
let file: &str = "./resources/file.xml";
let paths: String = ADBCmd::get_file_path(file).unwrap();
let args: Vec<String> = vec!["push".to_string(), paths, "/sdcard/".to_string()];
let res: Result<String, String> = ADBCmd::new("adb", true).run(&args);
...
...
}
pub mod tests {
use crate::cmd::{ADBCmd, ADBCmdTrait};
use super::*;
use tokio;
#[test]
fn test_adb_cmd() {
let path = ADBCmd::get_file_path("./resources/file.xml").unwrap();
let cleaned_path = path.replace("\\\\?\\", "");
let args = vec!["push".to_string(), cleaned_path, "/data/local/tmp/".to_string()];
let binding = ADBCmd::new("adb", false);
let result = binding.run(&args);
match result {
Ok(stdout) => println!("{}", stdout),
Err(stderr) => println!("{}", stderr),
}
}
#[tokio::test]
async fn test_run_async() {
let adb_cmd = ADBCmd::new("adb", false);
let args = vec!["devices".to_string()];
adb_cmd.run_async(args, |line| {
println!("{}", line);
line
}).await;
}
}