cargo_mobile2/doctor/
mod.rs

1mod section;
2
3use crate::{
4    env,
5    os::Env,
6    util::{self, cli::TextWrapper},
7};
8use thiserror::Error;
9
10// This should only be used for errors that we *really* don't expect and/or
11// that violate core assumptions made throughout the program.
12#[derive(Debug, Error)]
13pub enum Unrecoverable {
14    // Only encountered if the most basic environment variables are absent or
15    // unreadable
16    #[error(transparent)]
17    EnvInitFailed(#[from] env::Error),
18    // Only encountered if A) the user has no home directory, or B) either the
19    // home or some other path isn't valid UTF-8
20    #[error("Failed to prettify path: {0}")]
21    ContractHomeFailed(#[from] util::ContractHomeError),
22}
23
24pub fn exec(wrapper: &TextWrapper) -> Result<(), Unrecoverable> {
25    let env = Env::new()?;
26    section::cargo_mobile::check()?.print(wrapper);
27    #[cfg(target_os = "macos")]
28    section::apple::check().print(wrapper);
29    section::android::check(&env)?.print(wrapper);
30    section::device_list::check(&env).print(wrapper);
31    Ok(())
32}