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: ProjectStackWhich stack was detected for the current project.
runtime_version: Option<String>The detected runtime/toolchain version, when known.
env_file_exists: boolWhether a .env file exists at the project root.
env_example_exists: boolWhether a .env.example template exists at the project root.
dependencies_healthy: boolWhether 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: HealthScoreQuantitative health summary of the environment.
Implementations§
Source§impl EnvironmentState
impl EnvironmentState
Sourcepub fn ready_for_dev(&self) -> bool
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.
Sourcepub fn failed_checks(&self) -> usize
pub fn failed_checks(&self) -> usize
Number of failing diagnostics.
Sourcepub fn refresh_health(&mut self)
pub fn refresh_health(&mut self)
Rebuilds health_score from the current diagnostics.
Trait Implementations§
Source§impl Clone for EnvironmentState
impl Clone for EnvironmentState
Source§impl Debug for EnvironmentState
impl Debug for EnvironmentState
Source§impl Default for EnvironmentState
impl Default for EnvironmentState
Source§impl<'de> Deserialize<'de> for EnvironmentState
impl<'de> Deserialize<'de> for EnvironmentState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for EnvironmentState
Source§impl PartialEq for EnvironmentState
impl PartialEq for EnvironmentState
Source§impl Serialize for EnvironmentState
impl Serialize for EnvironmentState
impl StructuralPartialEq for EnvironmentState
Auto Trait Implementations§
impl Forget for EnvironmentState
impl Freeze for EnvironmentState
impl RefUnwindSafe for EnvironmentState
impl Send for EnvironmentState
impl Sync for EnvironmentState
impl Unpin for EnvironmentState
impl UnsafeUnpin for EnvironmentState
impl UnwindSafe for EnvironmentState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more