Struct adb_rust::cmd::ADBCmd

source ·
pub struct ADBCmd { /* private fields */ }
Expand description

ADBCmd allows you to execute adb commands asynchronously.

Trait Implementations§

source§

impl ADBCmdTrait for ADBCmd

source§

async fn run_async<F>(&self, args: Vec<String>, fnc: F)
where F: FnMut(String) -> String + 'static,


use std::process::Command;

use ADB::cmd::ADBCmd;

let adb_cmd = ADBCmd::new();
#[tokio::main]
adb_cmd.run_async(vec!["devices".to_string()], |line| {
    println!("{}", line);
    line
}).await;
source§

fn run(&self, args: Vec<String>) -> Result<String, String>

run runs the given adb command synchronously.

use std::process::Command;

use ADB::cmd::ADBCmd;

let adb_cmd = ADBCmd::new("cmd".to_string(),false);

let result = adb_cmd.run(vec!["devices".to_string()]);
source§

async fn get_var_arg(self, args: Vec<String>) -> bool

Get variable on command

 let mut arg=String::from("mmi");
 let exec_args=vec![];
 let args= vec![
    "ls".to_string(),
    "/system/bin/sxrmmi".to_string()
    ]
 let _prefix= ADBCmd::new("adb",false).get_var_arg(args);
 if _prefix.is_ok(){
     arg = format!("{}{}","sxr".to_string(),arg);
 }else{
     arg = format!("{}{}","ssnwt".to_string(),arg);
 }
 exec_args.push(arg);
 exec_args.push("stop".to_string());
 let res= ADBCmd::new("adb",false).run(exec_args);
  
source§

fn get_file_path(path: &str) -> Result<String, String>

获取文件路径

 let res= ADBCmd::new("adb",false).get_file_path("./resources/file.xml");
source§

fn new(cmd: String, is_shell: bool) -> Self

source§

fn create_cmd(self) -> Command

source§

impl Clone for ADBCmd

source§

fn clone(&self) -> ADBCmd

Returns a copy 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 ADBCmd

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for ADBCmd

§

impl RefUnwindSafe for ADBCmd

§

impl Send for ADBCmd

§

impl Sync for ADBCmd

§

impl Unpin for ADBCmd

§

impl UnwindSafe for ADBCmd

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> 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,

§

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>,

§

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>,

§

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.