Skip to main content

Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

One device on an AdbServer, named by its serial.

Implementations§

Source§

impl Device

Source

pub fn serial(&self) -> &str

Source

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.

Source

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.

Source

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.

Source

pub fn shell_stream_with( &self, command: &str, stdio: Stdio, ) -> Result<ShellStream>

Self::shell_stream with the command’s streams connected as stdio says.

Source

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.

Source

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.

Source

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.

Source

pub fn forward_tcp(&self, device: &str) -> Result<u16>

Forwards a free host TCP port, chosen by the server, to device.

Source

pub fn remove_forward(&self, host: &str) -> Result<()>

Removes the forward rule whose host side is host.

Source

pub fn forwards(&self) -> Result<Vec<Rule>>

This device’s forward rules.

Source

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).

Source

pub fn remove_reverse(&self, device: &str) -> Result<()>

Removes the reverse rule whose device side is device.

Source

pub fn reverses(&self) -> Result<Vec<Rule>>

adbd’s reverse rules on this device.

Source

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.

Source

pub fn open_abstract(&self, name: &str) -> Result<TcpStream>

Self::open_service for the abstract Unix socket name.

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more