pub struct Device { /* private fields */ }Expand description
One device on an AdbServer, named by its serial.
Implementations§
Source§impl Device
impl Device
pub fn serial(&self) -> &str
Sourcepub fn shell(&self, command: &str) -> Result<ShellOutput>
pub fn shell(&self, command: &str) -> Result<ShellOutput>
Runs command with shell protocol v2 and collects its output. Standard
input is closed at once, so a command that reads it sees end of file.
Sourcepub fn shell_until(
&self,
command: &str,
deadline: Instant,
) -> Result<ShellOutput>
pub fn shell_until( &self, command: &str, deadline: Instant, ) -> Result<ShellOutput>
Runs command as Self::shell does, bounded by deadline rather
than by the server’s timeout for each read: the output is read with
the time left to deadline, so that a command that prints nothing
for longer than that timeout, as am start -W while it waits for the
app’s first frame, completes within it (design D1 of
android-pass-fixes). A command that has not ended by deadline, or a
deadline already past, which runs nothing, fails with a timeout
(Error::is_timeout) whose message names the deadline; opening the
stream keeps the server’s timeout.
Sourcepub fn shell_stream(&self, command: &str) -> Result<ShellStream>
pub fn shell_stream(&self, command: &str) -> Result<ShellStream>
Starts command with shell protocol v2 and hands back the stream, for
output that must be read as it arrives. Closing the stream makes adbd
send SIGHUP to the command.
Sourcepub fn shell_stream_with(
&self,
command: &str,
stdio: Stdio,
) -> Result<ShellStream>
pub fn shell_stream_with( &self, command: &str, stdio: Stdio, ) -> Result<ShellStream>
Self::shell_stream with the command’s streams connected as stdio
says.
Sourcepub fn push(&self, local: &Path, remote: &str, mode: u32) -> Result<()>
pub fn push(&self, local: &Path, remote: &str, mode: u32) -> Result<()>
Copies the local file at local to remote with permission bits mode.
adbd copies the owner’s bits to group and other, so 0o644 arrives as 0666 and 0o755 as 0777; restrict the file afterwards if that matters.
Sourcepub fn push_bytes(&self, data: &[u8], remote: &str, mode: u32) -> Result<()>
pub fn push_bytes(&self, data: &[u8], remote: &str, mode: u32) -> Result<()>
Writes data to remote with permission bits mode, which adbd widens
as Self::push describes.
Sourcepub fn forward(&self, host: &str, device: &str) -> Result<Option<u16>>
pub fn forward(&self, host: &str, device: &str) -> Result<Option<u16>>
Installs adb forward <host> <device>. Returns the host port when the
host side is a TCP socket; tcp:0 lets the server pick a free one.
Sourcepub fn forward_tcp(&self, device: &str) -> Result<u16>
pub fn forward_tcp(&self, device: &str) -> Result<u16>
Forwards a free host TCP port, chosen by the server, to device.
Sourcepub fn remove_forward(&self, host: &str) -> Result<()>
pub fn remove_forward(&self, host: &str) -> Result<()>
Removes the forward rule whose host side is host.
Sourcepub fn reverse(&self, device: &str, host: &str) -> Result<()>
pub fn reverse(&self, device: &str, host: &str) -> Result<()>
Installs adb reverse <device> <host>: adbd listens on device and
relays each connection to host.
Remove a reverse rule only after the connections through it have closed and nothing on the device will dial it again: when a device-side connection arrives for a rule the server has already dropped, the adb server aborts (spike S6).
Sourcepub fn remove_reverse(&self, device: &str) -> Result<()>
pub fn remove_reverse(&self, device: &str) -> Result<()>
Removes the reverse rule whose device side is device.
Sourcepub fn open_service(&self, service: &str) -> Result<TcpStream>
pub fn open_service(&self, service: &str) -> Result<TcpStream>
Opens a device service such as localabstract:<name> or tcp:<port> as
a byte stream, with no forward rule. A service nothing listens on fails
with Error::Fail and the message closed. The stream is returned
without read or write deadlines; the caller sets its own.
Sourcepub fn open_abstract(&self, name: &str) -> Result<TcpStream>
pub fn open_abstract(&self, name: &str) -> Result<TcpStream>
Self::open_service for the abstract Unix socket name.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Device
impl RefUnwindSafe for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnsafeUnpin for Device
impl UnwindSafe for Device
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request