Skip to content

feat: implement API for providing custom index#241

Merged
vytautas-astrauskas-sensmetry merged 1 commit intomainfrom
feat/custom-meta-index
Mar 24, 2026
Merged

feat: implement API for providing custom index#241
vytautas-astrauskas-sensmetry merged 1 commit intomainfrom
feat/custom-meta-index

Conversation

@vytautas-astrauskas-sensmetry
Copy link
Copy Markdown
Collaborator

No description provided.

Comment on lines +236 to +246
pub fn update_index(
&mut self,
new_index: IndexMap<String, String>,
) -> Result<(), LocalSrcError> {
let mut meta = self
.get_meta()?
.unwrap_or_else(InterchangeProjectMetadataRaw::default);
meta.index = new_index;
self.put_meta(&meta, true)?;
Ok(())
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this only uses .get_meta() and .put_meta() (and nothing specific to LocalSrcProject) it should go with the other utility functions in the ProjectMut trait.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot do this anymore because 9314c8e added dependency on LocalSrcError.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? ProjectMut returns project-specific errors, so every project type can return their own variant of this error.

IMO not worth doing it now, as there is no current usecase for other project types.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProjectMut::Error is a type variable:

impl<T: ProjectRead> ProjectRead for &mut T {
type Error = T::Error;
. If we want to add set_index method to ProjectMut, then it has to be abstract in the trait and have a concrete implementation for each project type. Alternatively, we could have an abstract method create_metadata_error that has a concrete implementation for each project type. In both cases, the effort does not feel worth it the gains at the moment.

Copy link
Copy Markdown
Collaborator

@andrius-puksta-sensmetry andrius-puksta-sensmetry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@vytautas-astrauskas-sensmetry vytautas-astrauskas-sensmetry force-pushed the feat/custom-meta-index branch 2 times, most recently from f902bc5 to 9cb2fe0 Compare March 24, 2026 12:11
Signed-off-by: Vytautas Astrauskas <vytautas.astrauskas@sensmetry.com>
Co-authored-by: Victor Linroth <victor.linroth@sensmetry.com>
Co-authored-by: Andrius Pukšta <andrius.puksta@sensmetry.com>
Signed-off-by: Vytautas Astrauskas <vytautas.astrauskas@sensmetry.com>
@vytautas-astrauskas-sensmetry vytautas-astrauskas-sensmetry merged commit 6515b3f into main Mar 24, 2026
57 checks passed
@vytautas-astrauskas-sensmetry vytautas-astrauskas-sensmetry deleted the feat/custom-meta-index branch March 24, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants