-
Notifications
You must be signed in to change notification settings - Fork 8
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
Combine FsRepository and OpenFsRepository #1156
base: main
Are you sure you want to change the base?
Conversation
4e29bbf
to
086c6b9
Compare
086c6b9
to
d08ddba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one idea for ergonomics and to reduce the size of this changeset - but also it looks like a rebase is needed
crates/spfs/src/clean_test.rs
Outdated
@@ -269,7 +269,7 @@ async fn test_clean_manifest_renders(tmpdir: tempfile::TempDir) { | |||
.expect("failed to clean repo"); | |||
println!("{result:#?}"); | |||
|
|||
let files = list_files(fs_repo.renders.as_ref().unwrap().renders.root()); | |||
let files = list_files(fs_repo.fs_impl.renders.as_ref().unwrap().renders.root()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it work to use an impl std::ops::Deref
on the repo type to avoid needing all these new field accessors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!
Use the type state pattern to combine these two types into a single type. This is some groundwork for creating new types to represent repos that have renders or not. This code doesn't make much use of the type state pattern yet. `FsRepository` used to represent a repo that may not be opened yet, this is now represented by the type alias: type MaybeOpenFsRepository = FsRepository<MaybeOpenFsRepositoryImpl> An already opened repository has the same name, but is now a type alias: type OpenFsRepository = FsRepository<OpenFsRepositoryImpl> The original types have been renamed to these *Impl names: FsRepository -> MaybeOpenFsRepositoryImpl OpenFsRepository -> OpenFsRepositoryImpl Signed-off-by: J Robert Ray <[email protected]>
Allow some places to not have to write `fs_impl`. Signed-off-by: J Robert Ray <[email protected]>
d08ddba
to
ad7d528
Compare
FS: FsRepositoryOps, | ||
{ | ||
fn has_renders(&self) -> bool { | ||
self.fs_impl.has_renders() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that Deref can't be used in cases like this where it would get interpreted as a recursive call instead.
Use the type state pattern to combine these two types into a single type. This is some groundwork for creating new types to represent repos that have renders or not.
FsRepository
used to represent a repo that may not be opened yet, this is now represented by the type alias:An already opened repository has the same name, but is now a type alias:
The original types have been renamed to these *Impl names: