Skip to main content

EnvironmentState

Struct EnvironmentState 

Source
pub struct EnvironmentState {
    pub detected_stack: ProjectStack,
    pub runtime_version: Option<String>,
    pub env_file_exists: bool,
    pub env_example_exists: bool,
    pub dependencies_healthy: bool,
    pub blocked_ports: Vec<(u16, u32)>,
    pub diagnostics: Vec<DiagnosticResult>,
    pub health_score: HealthScore,
}
Expand description

A full snapshot of the detected development environment.

use limitless_cli::models::{CheckStatus, DiagnosticResult, EnvironmentState,
                            HealthScore, ProjectStack};

let state = EnvironmentState::default();
assert_eq!(state.detected_stack, ProjectStack::Unknown);
assert!(!state.env_file_exists);
assert!(state.health_score.is_healthy());

let mut state = EnvironmentState {
    detected_stack: ProjectStack::Rust { version: "1.98.0".into() },
    runtime_version: Some("1.98.0".into()),
    env_file_exists: true,
    env_example_exists: true,
    dependencies_healthy: true,
    blocked_ports: vec![],
    diagnostics: vec![DiagnosticResult::new(
        "Dependency Audit", CheckStatus::Pass, "cargo check clean",
    )],
    health_score: HealthScore::default(),
};
assert!(state.ready_for_dev());

state.blocked_ports.push((5432, 12345));
assert!(!state.ready_for_dev());

let json = serde_json::to_string(&state).unwrap();
let back: EnvironmentState = serde_json::from_str(&json).unwrap();
assert_eq!(state, back);

Fields§

§detected_stack: ProjectStack

Which stack was detected for the current project.

§runtime_version: Option<String>

The detected runtime/toolchain version, when known.

§env_file_exists: bool

Whether a .env file exists at the project root.

§env_example_exists: bool

Whether a .env.example template exists at the project root.

§dependencies_healthy: bool

Whether dependencies resolve/install cleanly.

§blocked_ports: Vec<(u16, u32)>

Ports found blocked while listening, as (port, pid) pairs.

§diagnostics: Vec<DiagnosticResult>

All diagnostics collected during the last scan.

§health_score: HealthScore

Quantitative health summary of the environment.

Implementations§

Source§

impl EnvironmentState

Source

pub fn ready_for_dev(&self) -> bool

Whether the environment is ready for day-to-day development.

Requires a known stack, healthy dependencies, at least one env file present, no failed checks, and no blocked ports.

Source

pub fn failed_checks(&self) -> usize

Number of failing diagnostics.

Source

pub fn refresh_health(&mut self)

Rebuilds health_score from the current diagnostics.

Trait Implementations§

Source§

impl Clone for EnvironmentState

Source§

fn clone(&self) -> Self

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 EnvironmentState

Source§

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

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

impl Default for EnvironmentState

Source§

fn default() -> Self

A blank environment: unknown stack, no files, healthy-by-default.

Source§

impl<'de> Deserialize<'de> for EnvironmentState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for EnvironmentState

Source§

impl PartialEq for EnvironmentState

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for EnvironmentState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for EnvironmentState

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.