-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem Description
Hi! I use a custom testing environment at work in which each file has its own fake (mocked) filesystem (backed by filesystem) and it's not exactly easy to make filesystem and file-identify work together, as file-identify uses the host filesystem API.
Proposed Solution
I have two approaches in mind:
- Either add a
filesystemfeature (or whichever name makes more sense) and add (for instance)file_identify::tags_from_fs_path, that takes an additionalimpl FileSystem(or even animpl FakeFileSystem) argument and uses this instead of the host FS APIs.
#[cfg(filesystem)]
pub fn tags_from_fake_path<F, P>(filesystem: &F, path: P) -> Result<TagSet>
where
F: FileSystem,
P: AsRef<Path>,
{
todo!()
}That'd be neat, but it adds coupling with a third-party library that is not exactly well maintained π
- Provide (for instance) a
file_identify::tags_from_partsfunction that takes more as arguments what it would normally get from the host FS APIs. Something along the lines of:
pub fn tags_from_path_pure<P, C>(path: P, content: C, metadata: &Metadata) -> Result<TagSet>
where
P: AsRef<Path>,
C: AsRef<[u8]>,
{
todo!()
}Where Metadata is a custom datatype, as the Metadata from the standard library cannot be constructed by the user.
That would certainly reduce coupling with third-party libraries, which I like, at the price of a more complex API.
I am fine with implementing and maintaining any of these two solutions or some variation of these. I'm also okay with any other solution that allows me to use file-identify without using host FS APIs. Let me know!
Alternatives Considered
No response
Impact Level
Medium - Useful for common use cases
Feature Type
- New file type support
- CLI improvement
- Library API enhancement
- Performance optimization
- Documentation improvement
- Developer experience
Use Case
Using file-identity with mocked filesystems in test suites.
Additional Context
No response