Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Export types so the Repository type can be fully specified #229

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,7 @@ pub use crate::{
repofile::snapshotfile::{
PathList, SnapshotGroup, SnapshotGroupCriterion, SnapshotOptions, StringList,
},
repository::{IndexedFull, OpenStatus, Repository, RepositoryOptions},
repository::{
FullIndex, IndexedFull, IndexedStatus, OpenStatus, Repository, RepositoryOptions,
},
};
30 changes: 28 additions & 2 deletions crates/core/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use pretty_assertions::assert_eq;
use rstest::{fixture, rstest};
use rustic_core::{
repofile::SnapshotFile, BackupOptions, CheckOptions, ConfigOptions, FindMatches, FindNode,
KeyOptions, LimitOption, LsOptions, NoProgressBars, OpenStatus, PathList, Repository,
RepositoryBackends, RepositoryOptions, RusticResult,
FullIndex, IndexedFull, IndexedStatus, KeyOptions, LimitOption, LsOptions, NoProgressBars,
OpenStatus, PathList, Repository, RepositoryBackends, RepositoryOptions, RusticResult,
};
use rustic_core::{
repofile::{Metadata, Node},
Expand Down Expand Up @@ -464,3 +464,29 @@ fn test_prune(

Ok(())
}

/// Verifies that users can create wrappers around repositories
/// without resorting to generics. The rationale is that such
/// types can be used to dynamically open, store, and cache repos.
///
/// See issue #277 for more context.
#[test]
fn test_wrapping_in_new_type() -> Result<()> {
struct Wrapper(Repository<NoProgressBars, IndexedStatus<FullIndex, OpenStatus>>);

impl Wrapper {
fn new() -> Result<Self> {
Ok(Self(set_up_repo()?.to_indexed()?))
}
}

/// Fake function that "does something" with a fully indexed repo
/// (without actually relying on any functionality for the test)
fn use_repo(_: &impl IndexedFull) {}

let collection: Vec<Wrapper> = vec![Wrapper::new()?, Wrapper::new()?];

collection.iter().map(|r| &r.0).for_each(use_repo);

Ok(())
}