Skip to main content

LaunchArgs

Struct LaunchArgs 

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

The launch arguments the app was started with.

An immutable snapshot: reading it never allocates, so composables may query it per frame. The platform replaces the whole snapshot when the launch parameters change (Android onNewIntent); it never mutates one in place.

Implementations§

Source§

impl LaunchArgs

Source

pub fn new( entries: impl IntoIterator<Item = (String, LaunchArgValue)>, debuggable: bool, ) -> Self

Builds a snapshot from named values.

Platform backends call this; apps read launch_args instead. A repeated name keeps the first value, matching a Bundle, where the later putExtra of the same key is what the caller has to avoid.

Source

pub fn is_debuggable(&self) -> bool

Whether the OS considers this build debuggable — Android’s ApplicationInfo.FLAG_DEBUGGABLE, cfg!(debug_assertions) elsewhere.

Gate debug and instrumentation options on this. It is the only check that stays correct in a shipped build: a release APK reports false even when someone passes the extras, so the options cannot be turned on from the outside.

Source

pub fn contains(&self, name: &str) -> bool

Whether an argument with this name was supplied, whatever its type.

The reference pattern is a single presence flag (ob_debug) that switches a whole block of options on.

Source

pub fn names(&self) -> impl Iterator<Item = &str>

The names supplied, in the order the platform reported them.

Source

pub fn len(&self) -> usize

The number of arguments supplied.

Source

pub fn is_empty(&self) -> bool

Whether the app was launched without any arguments.

Source

pub fn value(&self, name: &str) -> Option<&LaunchArgValue>

The raw value, in the type the platform delivered.

Source

pub fn boolean(&self, name: &str) -> Option<bool>

Reads a boolean argument.

Accepts a Bool value, or text spelled true/false, 1/0, yes/no, on/off in any case. A number is not coerced: an --ei flag 1 that was meant to be --ez flag true reads as None rather than silently enabling something.

Source

pub fn int(&self, name: &str) -> Option<i32>

Reads a 32-bit integer argument.

Accepts an Int, a Long that fits, or text.

Source

pub fn long(&self, name: &str) -> Option<i64>

Reads a 64-bit integer argument.

Accepts a Long, an Int, or text. Seeds are the usual case, and a seed written as --ei still reads back here.

Source

pub fn float(&self, name: &str) -> Option<f32>

Reads a float argument.

Accepts a Float, an integer widened to f32, or text.

Source

pub fn string(&self, name: &str) -> Option<&str>

Reads a text argument.

Only a value that was delivered as text answers here, matching Bundle.getString, which returns null for an int extra. Numbers are not formatted back into strings.

Trait Implementations§

Source§

impl Clone for LaunchArgs

Source§

fn clone(&self) -> LaunchArgs

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 LaunchArgs

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for LaunchArgs

Source§

fn default() -> LaunchArgs

Returns the “default value” for a type. Read more
Source§

impl PartialEq for LaunchArgs

Source§

fn eq(&self, other: &LaunchArgs) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LaunchArgs

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.