use std::ops::Deref;
use std::ops::DerefMut;
use super::fields::ProjectFields;
use super::git::CheckoutInfo;
use super::git::WorktreeStatus;
use super::info::ProjectInfo;
use super::info::Visibility;
use super::info::WorktreeHealth;
use super::paths;
use super::paths::AbsolutePath;
use super::paths::DisplayPath;
use super::paths::RootDirectoryName;
#[derive(Clone)]
pub(crate) struct NonRustProject {
pub(super) path: AbsolutePath,
pub(super) name: Option<String>,
pub(super) worktree_status: WorktreeStatus,
pub(super) project_info: ProjectInfo,
}
impl NonRustProject {
pub(crate) fn new(path: AbsolutePath, name: Option<String>) -> Self {
Self {
path,
name,
worktree_status: WorktreeStatus::default(),
project_info: ProjectInfo::default(),
}
}
}
impl ProjectFields for NonRustProject {
fn path(&self) -> &AbsolutePath { &self.path }
fn name(&self) -> Option<&str> { self.name.as_deref() }
fn visibility(&self) -> Visibility { self.project_info.visibility }
fn worktree_health(&self) -> WorktreeHealth { self.project_info.worktree_health }
fn disk_usage_bytes(&self) -> Option<u64> { self.project_info.disk_usage_bytes }
fn git_info(&self) -> Option<&CheckoutInfo> { self.project_info.local_git_state.info() }
fn info(&self) -> &ProjectInfo { &self.project_info }
fn display_path(&self) -> DisplayPath { self.path.display_path() }
fn root_directory_name(&self) -> RootDirectoryName {
RootDirectoryName(paths::directory_leaf(self.path.as_path()))
}
fn worktree_status(&self) -> &WorktreeStatus { &self.worktree_status }
}
impl Deref for NonRustProject {
type Target = ProjectInfo;
fn deref(&self) -> &ProjectInfo { &self.project_info }
}
impl DerefMut for NonRustProject {
fn deref_mut(&mut self) -> &mut ProjectInfo { &mut self.project_info }
}