Skip to main content

WorkstreamManager

Struct WorkstreamManager 

Source
pub struct WorkstreamManager;
Expand description

Two-layer workstream file lifecycle:

  1. workstreams.yaml = curated (user-owned, highest priority)
  2. workstreams.suggested.yaml = generated suggestions
  3. If neither exists, generate from events and write suggestions

Implementations§

Source§

impl WorkstreamManager

Source

pub const SUGGESTED_FILENAME: &'static str = SUGGESTED_FILENAME

Suggested file name (machine-generated proposals)

Source

pub const CURATED_FILENAME: &'static str = CURATED_FILENAME

Curated file name (user-owned source of truth)

Source

pub fn load_effective( out_dir: &Path, clusterer: &dyn WorkstreamClusterer, events: &[EventEnvelope], ) -> Result<WorkstreamsFile>

Load the effective workstreams for rendering.

Priority:

  1. workstreams.yaml if present
  2. workstreams.suggested.yaml if present
  3. generate via clusterer and persist suggested file
§Examples

When no files exist, clustering runs and writes workstreams.suggested.yaml:

use shiplog_workstreams::WorkstreamManager;
use shiplog_workstreams::RepoClusterer;

let dir = tempfile::tempdir().unwrap();
let ws = WorkstreamManager::load_effective(dir.path(), &RepoClusterer, &[]).unwrap();
assert!(ws.workstreams.is_empty());
assert!(WorkstreamManager::suggested_path(dir.path()).exists());
Source

pub fn write_suggested( out_dir: &Path, workstreams: &WorkstreamsFile, ) -> Result<()>

Write machine-generated suggested workstreams. This always overwrites workstreams.suggested.yaml.

§Examples
use shiplog_workstreams::WorkstreamManager;
use shiplog_schema::workstream::WorkstreamsFile;

let ws = WorkstreamsFile { version: 1, generated_at: Utc::now(), workstreams: vec![] };
let dir = tempfile::tempdir().unwrap();
WorkstreamManager::write_suggested(dir.path(), &ws).unwrap();
assert!(WorkstreamManager::suggested_path(dir.path()).exists());
Source

pub fn has_curated(out_dir: &Path) -> bool

Check whether the curated workstreams file exists.

§Examples
use shiplog_workstreams::WorkstreamManager;

let dir = tempfile::tempdir().unwrap();
assert!(!WorkstreamManager::has_curated(dir.path()));
Source

pub fn curated_path(out_dir: &Path) -> PathBuf

Get the curated file path.

§Examples
use shiplog_workstreams::WorkstreamManager;
use std::path::Path;

let path = WorkstreamManager::curated_path(Path::new("./out/run_1"));
assert!(path.ends_with("workstreams.yaml"));
Source

pub fn suggested_path(out_dir: &Path) -> PathBuf

Get the suggested file path.

§Examples
use shiplog_workstreams::WorkstreamManager;
use std::path::Path;

let path = WorkstreamManager::suggested_path(Path::new("./out/run_1"));
assert!(path.ends_with("workstreams.suggested.yaml"));
Source

pub fn try_load(out_dir: &Path) -> Result<Option<WorkstreamsFile>>

Try to load curated then suggested workstreams.

Returns None when neither file exists.

§Examples
use shiplog_workstreams::WorkstreamManager;

let dir = tempfile::tempdir().unwrap();
assert!(WorkstreamManager::try_load(dir.path()).unwrap().is_none());

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.