Skip to main content

claim

Function claim 

Source
pub fn claim<F>(
    app_id: &str,
    args: Vec<String>,
    on_forward: F,
) -> Result<Claim, Claimed>
where F: Fn(Vec<String>) + Send + Sync + 'static,
Expand description

Claims app_id for this process, or forwards args (normally std::env::args().skip(1)) to the process that already holds it.

on_forward receives each later launch’s arguments on the connection’s reader thread; the caller hands them to its UI thread (for example through its platform’s post-to-main mechanism) rather than touching UI state there. It must not block for long: the forwarding process waits for it to return.

§Errors

Returns Claimed::Forwarded when a running instance took args, and Claimed::NoBus when the session bus cannot be used or the owner did not take them.