diff --git a/adb_cli/src/handlers/local_commands.rs b/adb_cli/src/handlers/local_commands.rs index 38160ee..a894f68 100644 --- a/adb_cli/src/handlers/local_commands.rs +++ b/adb_cli/src/handlers/local_commands.rs @@ -1,9 +1,8 @@ use std::{fs::File, io::Write}; -use adb_client::{ADBListItemType, ADBServerDevice}; -use anyhow::{Result, anyhow}; - -use crate::models::{ADBCliResult, LocalDeviceCommand}; +use crate::ADBCliResult; +use crate::models::LocalDeviceCommand; +use adb_client::ADBServerDevice; pub fn handle_local_commands( mut device: ADBServerDevice, diff --git a/adb_cli/src/models/adb_cli_error.rs b/adb_cli/src/models/adb_cli_error.rs index 233b242..3767a64 100644 --- a/adb_cli/src/models/adb_cli_error.rs +++ b/adb_cli/src/models/adb_cli_error.rs @@ -69,6 +69,7 @@ impl From for ADBCliError { | RustADBError::UpgradeError(_) | RustADBError::MDNSError(_) | RustADBError::SendError(_) + | RustADBError::UnknownFileMode(_) | RustADBError::UnknownTransport(_) => Self::MayNeedAnIssue(value), // List of [`RustADBError`] that may occur in standard contexts and therefore do not require for issues RustADBError::ADBDeviceNotPaired diff --git a/adb_cli/src/models/device.rs b/adb_cli/src/models/device.rs index 824092a..13fcc7d 100644 --- a/adb_cli/src/models/device.rs +++ b/adb_cli/src/models/device.rs @@ -7,23 +7,13 @@ use super::RebootTypeCommand; #[derive(Parser, Debug)] pub enum DeviceCommands { /// Spawn an interactive shell or run a list of commands on the device - Shell { - commands: Vec, - }, + Shell { commands: Vec }, /// Pull a file from device - Pull { - source: String, - destination: String, - }, + Pull { source: String, destination: String }, /// Push a file on device - Push { - filename: String, - path: String, - }, + Push { filename: String, path: String }, /// Stat a file on device - Stat { - path: String, - }, + Stat { path: String }, /// Run an activity on device specified by the intent Run { /// The package whose activity is to be invoked @@ -53,7 +43,9 @@ pub enum DeviceCommands { /// Framebuffer image destination path path: String, }, + /// List files on device List { + /// Path to list files from path: String, }, } diff --git a/adb_client/src/device/commands/list.rs b/adb_client/src/device/commands/list.rs index 4cb3e07..c0e4f12 100644 --- a/adb_client/src/device/commands/list.rs +++ b/adb_client/src/device/commands/list.rs @@ -2,7 +2,7 @@ use crate::{ ADBListItem, ADBListItemType, ADBMessageTransport, Result, RustADBError, device::{ ADBTransportMessage, MessageCommand, MessageSubcommand, - adb_message_device::ADBMessageDevice, + adb_message_device::{ADBMessageDevice, bincode_serialize_to_vec}, }, }; use byteorder::ByteOrder; @@ -27,13 +27,13 @@ impl ADBMessageDevice { /// It reads the request bytes across the existing payload, and if there is not enough bytes left, /// reads the rest from the next payload /// - /// Current index - /// ┼───────────────┼ Requested - /// ┌─────────────┐ - /// ┌───────────────┼───────┐ │ - /// └───────────────────────┘ - /// Current └─────┘ - /// payload Wanted in + /// Current index + /// ┼───────────────┼ Requested + /// ┌─────────────┐ + /// ┌───────────────┼───────┐ │ + /// └───────────────────────┘ + /// Current └─────┘ + /// payload Wanted in /// Next payload fn read_bytes_from_transport( requested_bytes: &usize, @@ -79,10 +79,10 @@ impl ADBMessageDevice { let mut len_buf = Vec::from([0_u8; 4]); LittleEndian::write_u32(&mut len_buf, path.as_ref().len() as u32); - let subcommand_data = MessageSubcommand::List; //.with_arg(path.len() as u32); + let subcommand_data = MessageSubcommand::List; - let mut serialized_message = - bincode::serialize(&subcommand_data).map_err(|_e| RustADBError::ConversionError)?; + let mut serialized_message = bincode_serialize_to_vec(subcommand_data) + .map_err(|_e| RustADBError::ConversionError)?; serialized_message.append(&mut len_buf); let mut path_bytes: Vec = Vec::from(path.as_ref().as_bytes());