MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / console_port_for_avd_index

Function console_port_for_avd_index

packages/server/src/android.rs:1789–1801  ·  view source on GitHub ↗
(index: usize)

Source from the content-addressed store, hash-verified

1787}
1788
1789fn console_port_for_avd_index(index: usize) -> Result<u16, AppError> {
1790 let index = u16::try_from(index).map_err(|_| {
1791 AppError::native("Android emulator console port overflowed while deriving ports.")
1792 })?;
1793 let console_offset = index.checked_mul(2).ok_or_else(|| {
1794 AppError::native("Android emulator console port overflowed while deriving ports.")
1795 })?;
1796 DEFAULT_EMULATOR_CONSOLE_PORT_BASE
1797 .checked_add(console_offset)
1798 .ok_or_else(|| {
1799 AppError::native("Android emulator console port overflowed while deriving ports.")
1800 })
1801}
1802
1803fn console_port_from_serial(serial: &str) -> Option<u16> {
1804 serial.strip_prefix("emulator-")?.parse::<u16>().ok()

Callers 2

list_devicesMethod · 0.85
console_port_for_avdMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected