Skip to content

Commit

Permalink
feat: fix doc + add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin L committed Nov 25, 2024
1 parent ce0fe6a commit d52e7c7
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/rust-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ jobs:
- name: Run formatter
run : cargo fmt --all --check

doc:
name: "doc"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run doc
run : cargo doc --all-features --keep-going --offline

tests:
name: "tests"
runs-on: ubuntu-latest
Expand Down
10 changes: 5 additions & 5 deletions adb_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ let mut server = ADBServer::new(SocketAddrV4::new(server_ip, server_port));
server.devices();
```

### Using ADB server as proxy
### Using ADB server as bridge

#### [TCP] Launch a command on device
#### Launch a command on device

```rust no_run
use adb_client::{ADBServer, ADBDeviceExt};
Expand All @@ -43,7 +43,7 @@ let mut device = server.get_device().expect("cannot get device");
device.shell_command(["df", "-h"],std::io::stdout());
```

#### [TCP] Push a file to the device
#### Push a file to the device

```rust no_run
use adb_client::ADBServer;
Expand All @@ -59,7 +59,7 @@ device.push(&mut input, "/data/local/tmp");

### Interacting directly with device

#### [USB] Launch a command on device
#### (USB) Launch a command on device

```rust no_run
use adb_client::{ADBUSBDevice, ADBDeviceExt};
Expand All @@ -70,7 +70,7 @@ let mut device = ADBUSBDevice::new(vendor_id, product_id).expect("cannot find de
device.shell_command(["df", "-h"],std::io::stdout());
```

#### [USB] Push a file to the device
#### (USB) Push a file to the device

```rust no_run
use adb_client::{ADBUSBDevice, ADBDeviceExt};
Expand Down
12 changes: 6 additions & 6 deletions adb_client/src/adb_device_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ use std::path::Path;
use crate::models::AdbStatResponse;
use crate::{RebootType, Result};

/// Trait representing all features available on both [`ADBServerDevice`] and [`ADBMessageDevice<T>`] ([`ADBUSBDevice`])
/// Trait representing all features available on devices.
pub trait ADBDeviceExt {
/// Runs 'command' in a shell on the device, and write its output and error streams into [`output`].
/// Runs 'command' in a shell on the device, and write its output and error streams into `output`.
fn shell_command<S: ToString, W: Write>(
&mut self,
command: impl IntoIterator<Item = S>,
output: W,
) -> Result<()>;

/// Starts an interactive shell session on the device.
/// Input data is read from [reader] and write to [writer].
/// [W] has a 'static bound as it is internally used in a thread.
/// Input data is read from `reader` and write to `writer`.
/// `W` has a 'static bound as it is internally used in a thread.
fn shell<R: Read, W: Write + Send + 'static>(&mut self, reader: R, writer: W) -> Result<()>;

/// Display the stat information for a remote file
fn stat(&mut self, remote_path: &str) -> Result<AdbStatResponse>;

/// Pull the remote file pointed to by [source] and write its contents into [`output`]
/// Pull the remote file pointed to by `source` and write its contents into `output`
fn pull<A: AsRef<str>, W: Write>(&mut self, source: A, output: W) -> Result<()>;

/// Push [stream] to [path] on the device.
/// Push `stream` to `path` on the device.
fn push<R: Read, A: AsRef<str>>(&mut self, stream: R, path: A) -> Result<()>;

/// Reboots the device using given reboot type
Expand Down
2 changes: 1 addition & 1 deletion adb_client/src/server_device/commands/framebuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl TryFrom<[u8; std::mem::size_of::<Self>()]> for FrameBufferInfoV2 {

impl ADBServerDevice {
/// Dump framebuffer of this device into given ['path']
/// Big help from source code (https://android.googlesource.com/platform/system/adb/+/refs/heads/main/framebuffer_service.cpp)
/// Big help from source code (<https://android.googlesource.com/platform/system/adb/+/refs/heads/main/framebuffer_service.cpp>)
pub fn framebuffer<P: AsRef<Path>>(&mut self, path: P) -> Result<()> {
let img = self.framebuffer_inner()?;
Ok(img.save(path.as_ref())?)
Expand Down
2 changes: 1 addition & 1 deletion adb_client/src/server_device/commands/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
};

impl ADBServerDevice {
/// Lists files in [path] on the device.
/// Lists files in `path` on the device.
pub fn list<A: AsRef<str>>(&mut self, path: A) -> Result<()> {
let serial = self.identifier.clone();
self.connect()?
Expand Down
2 changes: 1 addition & 1 deletion adb_client/src/server_device/commands/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<R: Read> Read for ADBRecvCommandReader<R> {
}

impl ADBServerDevice {
/// Receives [path] to [stream] from the device.
/// Receives `path` to `stream` from the device.
pub fn pull<A: AsRef<str>>(&mut self, path: A, stream: &mut dyn Write) -> Result<()> {
let serial = self.identifier.clone();
self.connect()?
Expand Down
2 changes: 1 addition & 1 deletion adb_client/src/server_device/commands/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<W: Write> Write for ADBSendCommandWriter<W> {
}

impl ADBServerDevice {
/// Send [stream] to [path] on the device.
/// Send `stream` to `path` on the device.
pub fn push<R: Read, A: AsRef<str>>(&mut self, stream: R, path: A) -> Result<()> {
log::info!("Sending data to {}", path.as_ref());
let serial = self.identifier.clone();
Expand Down
2 changes: 1 addition & 1 deletion adb_client/src/server_device/commands/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl ADBServerDevice {
}
}

/// Stat file given as [path] on the device.
/// Stat file given as `path` on the device.
pub fn stat<A: AsRef<str>>(&mut self, path: A) -> Result<AdbStatResponse> {
let serial = self.identifier.clone();
self.connect()?
Expand Down

0 comments on commit d52e7c7

Please sign in to comment.