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
impl LaunchArgs
Sourcepub fn new(
entries: impl IntoIterator<Item = (String, LaunchArgValue)>,
debuggable: bool,
) -> Self
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.
Sourcepub fn is_debuggable(&self) -> bool
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.
Sourcepub fn contains(&self, name: &str) -> bool
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.
Sourcepub fn names(&self) -> impl Iterator<Item = &str>
pub fn names(&self) -> impl Iterator<Item = &str>
The names supplied, in the order the platform reported them.
Sourcepub fn value(&self, name: &str) -> Option<&LaunchArgValue>
pub fn value(&self, name: &str) -> Option<&LaunchArgValue>
The raw value, in the type the platform delivered.
Sourcepub fn boolean(&self, name: &str) -> Option<bool>
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.
Sourcepub fn int(&self, name: &str) -> Option<i32>
pub fn int(&self, name: &str) -> Option<i32>
Reads a 32-bit integer argument.
Accepts an Int, a Long that fits, or text.
Sourcepub fn long(&self, name: &str) -> Option<i64>
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.
Trait Implementations§
Source§impl Clone for LaunchArgs
impl Clone for LaunchArgs
Source§fn clone(&self) -> LaunchArgs
fn clone(&self) -> LaunchArgs
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more