Skip to main content

forge_primitives/
project_key.rs

1//! `ProjectKey` - the canonical on-disk project identity.
2//!
3//! Lives in forge-primitives so one key addresses a project across the
4//! crates that key their own maps on it - the workspace and the server -
5//! without either growing its own near-identical newtype.
6
7/// Project root path key - the canonicalised, sanitised string form
8/// produced by `forge_agent::userdata::catalog::scan::project_key_for_directory`.
9/// Equivalent to the directory names you see under
10/// `<config_dir>/projects/`.
11#[derive(Clone, Debug, Hash, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
12pub struct ProjectKey(pub(crate) String);
13
14impl ProjectKey {
15    pub fn new(key: impl Into<String>) -> Self {
16        Self(key.into())
17    }
18
19    pub fn as_str(&self) -> &str {
20        &self.0
21    }
22}