-
Notifications
You must be signed in to change notification settings - Fork 14
Remove reference to file in AudioProperties and Tag #9
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
base: master
Are you sure you want to change the base?
Remove reference to file in AudioProperties and Tag #9
Conversation
The Tag and AudioProperties structs were keeping a reference to the file object, making it hard to use them in isolation. For example doing the following complains about `f` not living long enough: ```rust taglib::File::new(path).and_then(|f| f.tag()) ```
Previously a handle to `File` was kept around in `Tag` and `AudioProperties` so that the raw file pointer wouldn't be dropped while it was being used. This made it difficult to just pass the tag around as a user of the API, due to having to keep the `file` object alive as well. For example, this would result in a lifetime error because the file object does not live long enough: ``` taglib::File::new(path).and_then(|f| f.tag()) ``` In this change the `Tag` and `AudioProperties` are created when request from the file, E.g. `file.tag()` and there is no raw pointers being passed around. If the user wishes to save new tags they pass the tag struct in to the `save` function directly instead (`AudioProperties` can't be changed).
258db25 to
885a5b0
Compare
|
Looks like this PR might sit here for a while based on my observation of the others. If anyone is interested in my changes feel free to use my repository in the meantime. |
|
Looks good! After manual merge of #8 with changes, I need to tidy this up before merge which might take a bit. |
|
Hmm, either I've messed up doing manual merge on your patch to master, or something is wrong with the patch itself, because after |
|
It also likely makes sense to have tag fields allow |

Previously a handle to
Filewas kept around inTagandAudioPropertiesso that the raw file pointer wouldn't be dropped while it was being used.
This made it difficult to just pass the tag around as a user of the API,
due to having to keep the
fileobject alive as well.For example, this would result in a lifetime error because the file object
does not live long enough:
In this change the
TagandAudioPropertiesare created when request fromthe file, E.g.
file.tag()and there is no raw pointers being passed around.If the user wishes to save new tags they pass the tag struct in to the
savefunction directly instead (
AudioPropertiescan't be changed).This fixes the issue for PR #7 causing a failure because of the file pointer deallocation. It also (unfortunately) includes the changes proposed in PR #8 as I was doing both of the changes concurrently.