pub struct EmulatorClient { /* private fields */ }Expand description
High-level client for controlling an Android Emulator via gRPC
This is a wrapper around the generated EmulatorControllerClient that provides
a more convenient API.
Implementations§
Source§impl EmulatorClient
impl EmulatorClient
Sourcepub async fn connect_avd(avd: &str) -> Result<Self>
pub async fn connect_avd(avd: &str) -> Result<Self>
Try to find an emulator running the specified AVD and connect to it
Sourcepub async fn connect(endpoint: impl Into<String>) -> Result<Self>
pub async fn connect(endpoint: impl Into<String>) -> Result<Self>
Connect to an emulator at the specified endpoint without authentication
Sourcepub async fn connect_with_auth(
endpoint: impl Into<String>,
provider: AuthProvider,
) -> Result<Self>
pub async fn connect_with_auth( endpoint: impl Into<String>, provider: AuthProvider, ) -> Result<Self>
Connect to an emulator with JWT authentication
Sourcepub fn auth_scheme(&self) -> &AuthScheme
pub fn auth_scheme(&self) -> &AuthScheme
Get the authentication scheme used by this client
Sourcepub fn export_token(&self, auds: &[&str], ttl: Duration) -> Result<BearerToken>
pub fn export_token(&self, auds: &[&str], ttl: Duration) -> Result<BearerToken>
Export a bearer token for the given audiences and TTL
This can be used to export a token with specific, limited audience claims in order to grant something limited access to the emulator.
Each audience in auds will be included as an aud claim in the token
and should correspond to the gRPC method patterns defined in the
allowlist.
This is only applicable when Self::auth_scheme() returns
auth::AuthScheme::Jwt.
Sourcepub fn protocol_mut(
&mut self,
) -> &mut EmulatorControllerClient<InterceptedService<Channel, AuthProvider>>
pub fn protocol_mut( &mut self, ) -> &mut EmulatorControllerClient<InterceptedService<Channel, AuthProvider>>
Get a mutable reference to the generated gRPC client protobuf binding
Sourcepub fn protocol(
&self,
) -> &EmulatorControllerClient<InterceptedService<Channel, AuthProvider>>
pub fn protocol( &self, ) -> &EmulatorControllerClient<InterceptedService<Channel, AuthProvider>>
Get a reference to the generated gRPC client protobuf binding
Sourcepub async fn wait_until_booted(
&mut self,
timeout: Duration,
poll_interval: Option<Duration>,
) -> Result<Duration>
pub async fn wait_until_booted( &mut self, timeout: Duration, poll_interval: Option<Duration>, ) -> Result<Duration>
Wait until the emulator has fully booted
This method polls the emulator’s boot status until it reports as booted, or until the specified timeout is reached.
§Arguments
timeout- Maximum duration to wait for the emulator to bootpoll_interval- Duration to wait between boot status checks (defaults to 2 seconds if None)
§Returns
Returns Ok(Duration) with the time elapsed until boot completed, or an error if the
timeout is reached or a gRPC error occurs.
§Errors
Returns EmulatorError::ConnectionTimeout if the emulator doesn’t boot within the timeout period.
Returns EmulatorError::GrpcStatus if there’s a gRPC communication error.
§Example
use android_emulator::EmulatorClient;
use std::time::Duration;
let mut client = EmulatorClient::connect("http://localhost:8554").await?;
// Wait up to 5 minutes for boot, checking every 2 seconds
let elapsed = client.wait_until_booted(Duration::from_secs(300), None).await?;
println!("Emulator booted in {:.1} seconds", elapsed.as_secs_f64());Auto Trait Implementations§
impl !Freeze for EmulatorClient
impl !RefUnwindSafe for EmulatorClient
impl Send for EmulatorClient
impl Sync for EmulatorClient
impl Unpin for EmulatorClient
impl !UnwindSafe for EmulatorClient
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> 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