Skip to main content

RequirementsStore

Struct RequirementsStore 

Source
pub struct RequirementsStore {
Show 22 fields pub name: String, pub title: String, pub description: String, pub requirements: Vec<Requirement>, pub users: Vec<User>, pub teams: Vec<Team>, pub id_config: IdConfiguration, pub features: Vec<FeatureDefinition>, pub next_feature_number: u32, pub next_spec_number: u32, pub prefix_counters: HashMap<String, u32>, pub relationship_definitions: Vec<RelationshipDefinition>, pub reaction_definitions: Vec<ReactionDefinition>, pub meta_counters: HashMap<String, u32>, pub type_definitions: Vec<CustomTypeDefinition>, pub allowed_prefixes: Vec<String>, pub restrict_prefixes: bool, pub ai_prompts: AiPromptConfig, pub baselines: Vec<Baseline>, pub store_version: i64, pub migrated_to: Option<String>, pub dispenser: Option<DispenserHandle>,
}
Expand description

Collection of all requirements

Fields§

§name: String

Database name (displayed in window title prefix)

§title: String

Database title (one-liner, displayed in window title)

§description: String

Database description (multi-line)

§requirements: Vec<Requirement>§users: Vec<User>

Users in the system

§teams: Vec<Team>

Teams in the system

§id_config: IdConfiguration

ID system configuration

§features: Vec<FeatureDefinition>

Defined features with their prefixes

§next_feature_number: u32

Counter for feature numbers (used when creating new features)

§next_spec_number: u32

Global counter for requirement IDs (used with Global numbering strategy)

§prefix_counters: HashMap<String, u32>

Per-prefix counters for requirement IDs (used with PerPrefix numbering) Key is the prefix (e.g., “FR”, “AUTH”), value is the next number

§relationship_definitions: Vec<RelationshipDefinition>

Relationship type definitions with constraints

§reaction_definitions: Vec<ReactionDefinition>

Reaction definitions for comments

§meta_counters: HashMap<String, u32>

Counter for meta-type IDs (users, views, etc.) - maps prefix to next number e.g., “$USER” -> 1 means next user will be $USER-001

§type_definitions: Vec<CustomTypeDefinition>

Custom type definitions with their statuses and fields

§allowed_prefixes: Vec<String>

List of allowed/known ID prefixes for the project These are collected from usage and can be managed by admins

§restrict_prefixes: bool

Whether to restrict prefix selection to only allowed_prefixes When false, users can enter any valid prefix (which gets added to allowed_prefixes) When true, users must select from the allowed_prefixes list

§ai_prompts: AiPromptConfig

AI prompt configuration for customizing AI behavior

§baselines: Vec<Baseline>

Baselines - named snapshots of requirements at specific points in time

§store_version: i64

Store version for detecting external modifications (SQLite only) Incremented on each save, used to detect if store was modified externally

§migrated_to: Option<String>

Migration marker - if set, indicates this YAML was migrated to another format Contains the path to the migrated database (e.g., “requirements.db”) When this is set, opening the YAML should warn/redirect to the migrated database

§dispenser: Option<DispenserHandle>

Optional external dispenser for ID generation (distributed mode). When set, ID generation delegates to this dispenser instead of using the internal next_spec_number / prefix_counters fields. Skipped in serialization — the dispenser has its own persistence.

Implementations§

Source§

impl RequirementsStore

Source

pub fn new() -> Self

Creates an empty requirements store

Source

pub fn get_type_definition( &self, req_type: &RequirementType, ) -> Option<&CustomTypeDefinition>

Gets the type definition for a requirement type

Source

pub fn get_statuses_for_type(&self, req_type: &RequirementType) -> Vec<String>

Gets the available statuses for a requirement type

Source

pub fn get_priorities_for_type(&self, req_type: &RequirementType) -> Vec<String>

Gets the available priorities for a requirement type

Source

pub fn get_custom_fields_for_type( &self, req_type: &RequirementType, ) -> Vec<CustomFieldDefinition>

Gets the custom field definitions for a requirement type

Source

pub fn is_type_stateless(&self, req_type: &RequirementType) -> bool

Checks if a requirement type is stateless (no status/priority tracking)

Source

pub fn get_sprints(&self) -> Vec<&Requirement>

Get all Sprints, sorted by sprint_number custom field (if available)

Source

pub fn get_sprint_items(&self, sprint_id: &Uuid) -> Vec<&Requirement>

Get items assigned to a specific Sprint via sprint_assignment relationship

Source

pub fn get_requirement_sprint(&self, req_id: &Uuid) -> Option<&Requirement>

Get the Sprint that a requirement is assigned to (if any)

Source

pub fn get_backlog(&self) -> Vec<&Requirement>

Get backlog items (requirements without Sprint assignment, excluding Sprints and Folders)

Source

pub fn assign_to_sprint( &mut self, req_id: Uuid, sprint_id: Uuid, username: &str, )

Assign a requirement to a Sprint This removes any existing sprint assignment and creates a new one

Source

pub fn remove_from_sprint(&mut self, req_id: Uuid, username: &str)

Remove a requirement from its Sprint assignment

Source

pub fn get_used_prefixes(&self) -> Vec<String>

Gets all unique prefixes currently in use from requirements

Source

pub fn get_all_prefixes(&self) -> Vec<String>

Gets all allowed prefixes (combines allowed_prefixes with used prefixes)

Source

pub fn add_allowed_prefix(&mut self, prefix: &str)

Adds a prefix to the allowed list if not already present

Source

pub fn remove_allowed_prefix(&mut self, prefix: &str)

Removes a prefix from the allowed list

Source

pub fn is_prefix_allowed(&self, prefix: &str) -> bool

Checks if a prefix is allowed (always true if restrict_prefixes is false)

Source

pub fn next_meta_id(&mut self, prefix: &str) -> String

Generates the next meta-type ID for a given prefix (e.g., “$USER” -> “$USER-001”)

Source

pub fn add_requirement(&mut self, req: Requirement)

Adds a requirement to the store

Source

pub fn add_user(&mut self, user: User)

Adds a user to the store (legacy - no spec_id)

Source

pub fn add_user_with_id( &mut self, name: String, email: String, handle: String, ) -> String

Adds a user with auto-generated $USER-XXX spec_id

Source

pub fn find_user_by_spec_id(&self, spec_id: &str) -> Option<&User>

Finds a user by spec_id (e.g., “$USER-001”)

Source

pub fn find_user_by_spec_id_mut(&mut self, spec_id: &str) -> Option<&mut User>

Finds a user by spec_id (mutable)

Source

pub fn find_user_by_id(&self, id: &Uuid) -> Option<&User>

Finds a user by UUID

Source

pub fn migrate_users_to_spec_ids(&mut self)

Migrates existing users without spec_id to have $USER-XXX IDs

Source

pub fn get_user_by_id_mut(&mut self, id: &Uuid) -> Option<&mut User>

Gets a mutable reference to a user by ID

Source

pub fn remove_user(&mut self, id: &Uuid) -> bool

Removes a user by ID

Source

pub fn add_team(&mut self, team: Team)

Adds a team to the store (legacy - no spec_id)

Source

pub fn add_team_with_id( &mut self, name: String, description: String, parent_team_id: Option<Uuid>, ) -> String

Adds a team with auto-generated $TEAM-XXX spec_id

Source

pub fn find_team_by_spec_id(&self, spec_id: &str) -> Option<&Team>

Finds a team by spec_id (e.g., “$TEAM-001”)

Source

pub fn find_team_by_spec_id_mut(&mut self, spec_id: &str) -> Option<&mut Team>

Finds a team by spec_id (mutable)

Source

pub fn find_team_by_id(&self, id: &Uuid) -> Option<&Team>

Finds a team by UUID

Source

pub fn get_team_by_id_mut(&mut self, id: &Uuid) -> Option<&mut Team>

Gets a mutable reference to a team by ID

Source

pub fn remove_team(&mut self, id: &Uuid) -> bool

Removes a team by ID

Source

pub fn get_child_teams(&self, parent_id: &Uuid) -> Vec<&Team>

Gets child teams for a given parent team

Source

pub fn get_root_teams(&self) -> Vec<&Team>

Gets top-level teams (teams without a parent)

Source

pub fn get_teams_for_user(&self, user_id: &Uuid) -> Vec<&Team>

Gets all teams a user belongs to

Source

pub fn would_create_team_cycle( &self, team_id: &Uuid, proposed_parent_id: &Uuid, ) -> bool

Checks if setting a parent team would create a circular reference

Source

pub fn migrate_teams_to_spec_ids(&mut self)

Migrates existing teams without spec_id to have $TEAM-XXX IDs

Source

pub fn get_requirement_by_id(&self, id: &Uuid) -> Option<&Requirement>

Gets a requirement by ID

Source

pub fn get_requirement_by_id_mut( &mut self, id: &Uuid, ) -> Option<&mut Requirement>

Gets a mutable reference to a requirement by ID

Source

pub fn get_next_feature_number(&mut self) -> u32

Gets the next feature number and increments the counter

Source

pub fn format_feature_with_number(&self, feature_name: &str) -> String

Formats a feature with number prefix

Source

pub fn get_feature_names(&self) -> Vec<String>

Gets all unique feature names

Source

pub fn update_feature_name(&mut self, old_name: &str, new_name: &str)

Updates an existing feature name

Source

pub fn migrate_features(&mut self)

Migrate existing features to use numbered prefixes

Source

pub fn get_requirement_by_spec_id(&self, spec_id: &str) -> Option<&Requirement>

Gets a requirement by SPEC-ID

Source

pub fn get_requirement_by_spec_id_mut( &mut self, spec_id: &str, ) -> Option<&mut Requirement>

Gets a mutable reference to a requirement by SPEC-ID

Source

pub fn assign_spec_ids(&mut self)

Assigns SPEC-IDs to requirements that don’t have them

Source

pub fn peek_next_spec_id(&self) -> String

Gets the next SPEC-ID that would be assigned

Source

pub fn validate_unique_spec_ids(&self) -> Result<()>

Validates that all SPEC-IDs are unique

Source

pub fn repair_duplicate_spec_ids(&mut self) -> usize

Repairs duplicate SPEC-IDs by assigning new unique IDs to duplicates Keeps the first occurrence of each SPEC-ID, reassigns duplicates Returns the number of duplicates that were repaired

Source

pub fn add_requirement_with_spec_id(&mut self, req: Requirement)

Adds a requirement and assigns it a SPEC-ID (legacy method for backward compatibility)

Source

pub fn migrate_type_definitions(&mut self) -> bool

Migrates type definitions by adding any missing built-in types Returns true if any types were added

Source

pub fn migrate_id_config_types(&mut self) -> bool

Migrates id_config.requirement_types by adding any missing built-in types This ensures CLI type list shows all built-in types Returns true if any types were added

Source

pub fn add_feature( &mut self, name: &str, prefix: &str, ) -> Result<FeatureDefinition>

Add a new feature definition Returns error if the prefix is reserved or already in use

Source

pub fn get_feature_by_name(&self, name: &str) -> Option<&FeatureDefinition>

Get a feature by name

Source

pub fn get_feature_by_prefix(&self, prefix: &str) -> Option<&FeatureDefinition>

Get a feature by prefix

Source

pub fn generate_requirement_id( &mut self, feature_prefix: Option<&str>, type_prefix: Option<&str>, ) -> String

Generate a new requirement ID based on configuration

  • feature_prefix: Optional feature prefix (e.g., “AUTH”)
  • type_prefix: Optional type prefix (e.g., “FR”)
Source

pub fn add_requirement_with_id( &mut self, req: Requirement, feature_prefix: Option<&str>, type_prefix: Option<&str>, )

Add a requirement with the new ID system If spec_id is already set, uses that; otherwise generates one If prefix_override is set on the requirement, uses that prefix instead of feature/type

Source

pub fn get_type_prefix(&self, req_type: &RequirementType) -> Option<String>

Get the type prefix for a RequirementType enum value Falls back to built-in defaults if the type is not in the database

Source

pub fn regenerate_spec_id_for_prefix_change( &mut self, req_uuid: &Uuid, new_prefix: Option<&str>, feature_prefix: Option<&str>, type_prefix: Option<&str>, ) -> Result<String, String>

Generate a new spec_id for a requirement with a new prefix override Returns Ok(new_spec_id) if successful, Err if the new ID would conflict

Source

pub fn is_spec_id_available( &self, spec_id: &str, exclude_uuid: Option<&Uuid>, ) -> bool

Check if a spec_id is available (not used by any requirement, or only by the given UUID)

Source

pub fn update_spec_id_for_type_change( &self, current_spec_id: Option<&str>, new_type: &RequirementType, ) -> Option<String>

Update a requirement’s spec_id when its type changes Replaces the type prefix portion while keeping the number

Source

pub fn migrate_to_new_id_format(&mut self)

Migrate all existing SPEC-XXX IDs to the new format This will regenerate all IDs based on the current configuration Requirements with prefix_override will use their override prefix

Source

pub fn validate_id_config_change( &self, new_format: &IdFormat, new_numbering: &NumberingStrategy, new_digits: u8, ) -> IdConfigValidation

Validate proposed changes to ID configuration Returns validation result with error/warning messages

Source

pub fn get_max_digits_in_use(&self) -> u8

Get the maximum number of digits currently used in requirement IDs

Source

pub fn migrate_ids_to_config( &mut self, new_format: IdFormat, new_numbering: NumberingStrategy, new_digits: u8, ) -> usize

Migrate requirement IDs to new format/numbering/digits configuration Returns the number of requirements migrated

Source

pub fn add_requirement_type( &mut self, name: &str, prefix: &str, description: &str, ) -> Result<()>

Add a new requirement type definition

Source

pub fn add_relationship( &mut self, source_id: &Uuid, rel_type: RelationshipType, target_id: &Uuid, bidirectional: bool, ) -> Result<()>

Add a relationship between two requirements

Source

pub fn add_relationship_with_creator( &mut self, source_id: &Uuid, rel_type: RelationshipType, target_id: &Uuid, bidirectional: bool, created_by: Option<String>, ) -> Result<()>

Add a relationship between two requirements with optional creator info

Source

pub fn set_relationship( &mut self, source_id: &Uuid, rel_type: RelationshipType, target_id: &Uuid, bidirectional: bool, ) -> Result<()>

Set a unique relationship, removing any existing relationship of the same type first This is useful for Parent relationships where a requirement can only have one parent

Source

pub fn set_relationship_with_creator( &mut self, source_id: &Uuid, rel_type: RelationshipType, target_id: &Uuid, bidirectional: bool, created_by: Option<String>, ) -> Result<()>

Set a unique relationship with creator info, removing any existing relationship of the same type first

Source

pub fn remove_relationship( &mut self, source_id: &Uuid, rel_type: &RelationshipType, target_id: &Uuid, bidirectional: bool, ) -> Result<()>

Remove a relationship between two requirements

Source

pub fn get_relationships(&self, id: &Uuid) -> Vec<(RelationshipType, Uuid)>

Get all relationships for a requirement

Source

pub fn get_relationships_by_type( &self, id: &Uuid, rel_type: &RelationshipType, ) -> Vec<Uuid>

Get all relationships of a specific type for a requirement

Source

pub fn get_relationship_definition( &self, name: &str, ) -> Option<&RelationshipDefinition>

Get a relationship definition by name

Source

pub fn get_definition_for_type( &self, rel_type: &RelationshipType, ) -> Option<&RelationshipDefinition>

Get a relationship definition for a RelationshipType

Source

pub fn get_relationship_definitions(&self) -> &[RelationshipDefinition]

Get all relationship definitions

Source

pub fn add_relationship_definition( &mut self, definition: RelationshipDefinition, ) -> Result<()>

Add a new relationship definition

Source

pub fn update_relationship_definition( &mut self, name: &str, definition: RelationshipDefinition, ) -> Result<()>

Update an existing relationship definition

Source

pub fn remove_relationship_definition(&mut self, name: &str) -> Result<()>

Remove a relationship definition (only non-built-in)

Source

pub fn ensure_builtin_relationships(&mut self)

Ensure built-in relationship definitions exist (call after loading)

Source

pub fn validate_relationship( &self, source_id: &Uuid, rel_type: &RelationshipType, target_id: &Uuid, ) -> RelationshipValidation

Validate a proposed relationship

Source

pub fn get_inverse_type( &self, rel_type: &RelationshipType, ) -> Option<RelationshipType>

Get the inverse relationship type from definitions

Source

pub fn create_baseline( &mut self, name: String, description: Option<String>, created_by: String, ) -> &Baseline

Creates a new baseline from current requirements

Source

pub fn get_baseline(&self, id: &Uuid) -> Option<&Baseline>

Gets a baseline by ID

Source

pub fn get_baseline_by_name(&self, name: &str) -> Option<&Baseline>

Gets a baseline by name

Source

pub fn delete_baseline(&mut self, id: &Uuid) -> bool

Deletes a baseline by ID (if not locked)

Source

pub fn compare_with_baseline( &self, baseline_id: &Uuid, ) -> Option<BaselineComparison>

Compares current requirements against a baseline

Source

pub fn compare_baselines( &self, source_id: &Uuid, target_id: &Uuid, ) -> Option<BaselineComparison>

Compares two baselines

Trait Implementations§

Source§

impl Clone for RequirementsStore

Source§

fn clone(&self) -> RequirementsStore

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RequirementsStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RequirementsStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for RequirementsStore

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RequirementsStore

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TS for RequirementsStore

Source§

type WithoutGenerics = RequirementsStore

If this type does not have generic parameters, then WithoutGenerics should just be Self. If the type does have generic parameters, then all generic parameters must be replaced with a dummy type, e.g ts_rs::Dummy or (). The only requirement for these dummy types is that EXPORT_TO must be None. Read more
Source§

type OptionInnerType = RequirementsStore

If the implementing type is std::option::Option<T>, then this associated type is set to T. All other implementations of TS should set this type to Self instead.
Source§

fn ident() -> String

Identifier of this type, excluding generic parameters.
Source§

fn docs() -> Option<String>

JSDoc comment to describe this type in TypeScript - when TS is derived, docs are automatically read from your doc comments or #[doc = ".."] attributes
Source§

fn name() -> String

Name of this type in TypeScript, including generic parameters
Source§

fn decl_concrete() -> String

Declaration of this type using the supplied generic arguments. The resulting TypeScript definition will not be generic. For that, see TS::decl(). If this type is not generic, then this function is equivalent to TS::decl().
Source§

fn decl() -> String

Declaration of this type, e.g. type User = { user_id: number, ... }. This function will panic if the type has no declaration. Read more
Source§

fn inline() -> String

Formats this types definition in TypeScript, e.g { user_id: number }. This function will panic if the type cannot be inlined.
Source§

fn inline_flattened() -> String

Flatten a type declaration.
This function will panic if the type cannot be flattened.
Source§

fn visit_generics(v: &mut impl TypeVisitor)
where Self: 'static,

Iterates over all type parameters of this type.
Source§

fn output_path() -> Option<PathBuf>

Returns the output path to where T should be exported.
The returned path does not include the base directory from TS_RS_EXPORT_DIR. Read more
Source§

fn visit_dependencies(v: &mut impl TypeVisitor)
where Self: 'static,

Iterates over all dependency of this type.
Source§

fn dependencies() -> Vec<Dependency>
where Self: 'static,

Resolves all dependencies of this type recursively.
Source§

fn export() -> Result<(), ExportError>
where Self: 'static,

Manually export this type to the filesystem. To export this type together with all of its dependencies, use TS::export_all. Read more
Source§

fn export_all() -> Result<(), ExportError>
where Self: 'static,

Manually export this type to the filesystem, together with all of its dependencies.
To export only this type, without its dependencies, use TS::export. Read more
Source§

fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>
where Self: 'static,

Manually export this type into the given directory, together with all of its dependencies.
To export only this type, without its dependencies, use TS::export. Read more
Source§

fn export_to_string() -> Result<String, ExportError>
where Self: 'static,

Manually generate bindings for this type, returning a String.
This function does not format the output, even if the format feature is enabled. Read more
Source§

fn default_output_path() -> Option<PathBuf>

Returns the output path to where T should be exported. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,