pub struct PlanStore { /* private fields */ }Expand description
Stores and retrieves plan artifacts for sessions.
Implementations§
Source§impl PlanStore
impl PlanStore
Sourcepub fn new(data_dir: impl AsRef<Path>) -> Result<Self, PlanStoreError>
pub fn new(data_dir: impl AsRef<Path>) -> Result<Self, PlanStoreError>
Create a new plan store with the given base data directory.
Artifacts are stored in {data_dir}/plan/.
Sourcepub fn session_dir_path(&self, session_id: &str) -> PathBuf
pub fn session_dir_path(&self, session_id: &str) -> PathBuf
Path to the session artifact directory for a given session.
Sourcepub fn plan_file_path(&self, session_id: &str) -> PathBuf
pub fn plan_file_path(&self, session_id: &str) -> PathBuf
Path to the plan markdown file for a given session.
Returns the currently resolved path. If a legacy flat-file artifact exists and the new directory-based artifact does not, this returns the legacy path.
Sourcepub fn state_file_path(&self, session_id: &str) -> PathBuf
pub fn state_file_path(&self, session_id: &str) -> PathBuf
Path to the plan machine state artifact for a given session.
Sourcepub fn cursor_file_path(&self, session_id: &str) -> PathBuf
pub fn cursor_file_path(&self, session_id: &str) -> PathBuf
Path to the plan cursor artifact for a given session.
Sourcepub fn sections_file_path(&self, session_id: &str) -> PathBuf
pub fn sections_file_path(&self, session_id: &str) -> PathBuf
Path to the indexed sections artifact for a given session.
Sourcepub fn write_plan(
&self,
session_id: &str,
content: impl AsRef<str>,
) -> Result<PathBuf, PlanStoreError>
pub fn write_plan( &self, session_id: &str, content: impl AsRef<str>, ) -> Result<PathBuf, PlanStoreError>
Write a plan markdown artifact for the given session.
Overwrites any existing directory-based artifact for this session and refreshes the section index artifact derived from the markdown.
Sourcepub fn read_plan(&self, session_id: &str) -> Option<String>
pub fn read_plan(&self, session_id: &str) -> Option<String>
Read the plan markdown artifact for the given session, if it exists.
Sourcepub fn plan_exists(&self, session_id: &str) -> bool
pub fn plan_exists(&self, session_id: &str) -> bool
Check whether a plan artifact exists for the given session.
Sourcepub fn write_state(
&self,
session_id: &str,
state: &PlanStateArtifact,
) -> Result<PathBuf, PlanStoreError>
pub fn write_state( &self, session_id: &str, state: &PlanStateArtifact, ) -> Result<PathBuf, PlanStoreError>
Write the plan machine state artifact for the given session.
Sourcepub fn read_state(
&self,
session_id: &str,
) -> Result<Option<PlanStateArtifact>, PlanStoreError>
pub fn read_state( &self, session_id: &str, ) -> Result<Option<PlanStateArtifact>, PlanStoreError>
Read the plan machine state artifact for the given session, if it exists.
Sourcepub fn write_cursor(
&self,
session_id: &str,
cursor: &PlanCursorArtifact,
) -> Result<PathBuf, PlanStoreError>
pub fn write_cursor( &self, session_id: &str, cursor: &PlanCursorArtifact, ) -> Result<PathBuf, PlanStoreError>
Write the plan cursor artifact for the given session.
Sourcepub fn read_cursor(
&self,
session_id: &str,
) -> Result<Option<PlanCursorArtifact>, PlanStoreError>
pub fn read_cursor( &self, session_id: &str, ) -> Result<Option<PlanCursorArtifact>, PlanStoreError>
Read the plan cursor artifact for the given session, if it exists.
Sourcepub fn read_sections(
&self,
session_id: &str,
) -> Result<Option<PlanSectionArtifact>, PlanStoreError>
pub fn read_sections( &self, session_id: &str, ) -> Result<Option<PlanSectionArtifact>, PlanStoreError>
Read the indexed plan sections artifact for the given session, if it exists.
Sourcepub fn delete_plan(&self, session_id: &str) -> Result<(), PlanStoreError>
pub fn delete_plan(&self, session_id: &str) -> Result<(), PlanStoreError>
Delete all plan artifacts for the given session.