Skip to content

cocool97/adb_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adb_client

Latest version MIT licensed dependency status Documentation

Android Debug Bridge (ADB) client implementation in pure Rust !

Main features :

  • Full Rust, no need to use adb * shell commands
  • Currently only support server TCP/IP protocol
  • Highly configurable
  • Easy to use !

Examples

First declare adb_client as a dependency by simply adding it to your Cargo.toml:

[dependencies]
adb_client = "*"

Launch a command on device via ADB server

use adb_client::ADBServer;

let mut server = ADBServer::default();
let mut device = server.get_device().expect("cannot get device");
device.shell_command(["df", "-h"]);

Get available ADB devices

use adb_client::ADBServer;
use std::net::{SocketAddrV4, Ipv4Addr};

// A custom server address can be provided
let server_ip = Ipv4Addr::new(127, 0, 0, 1);
let server_port = 5037;

let mut server = ADBServer::new(SocketAddrV4::new(server_ip, server_port));
server.devices();

Push a file to the device

use adb_client::ADBServer;
use std::net::Ipv4Addr;
use std::fs::File;
use std::path::Path;

let mut server = ADBServer::default();
let mut device = server.get_device().expect("cannot get device");
let mut input = File::open(Path::new("/tmp")).unwrap();
device.send(&mut input, "/data/local/tmp");

Rust binary

This crate also provides a lightweight binary based on the adb_client crate. You can install it by running the following command :

cargo install adb_cli 

Missing features

  • USB protocol

All pull requests are welcome !