-
Notifications
You must be signed in to change notification settings - Fork 58
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
[RFC] add a lifetime parameter to Transport::fetch and Repository::read_target #563
Conversation
…ad_target This is useful in cases where you're implementing a transport that borrows from the reader (e.g. if you're treating a zip file as the reader, returning [`ZipFile<'a>`](https://docs.rs/zip/latest/zip/read/struct.ZipFile.html)). This is a breaking change because `read_target` now borrows from `self`. I don't think that's a major issue, because in most cases you're going to keep the `Repository` open for longer than any of the files.
Thank you for this PR. On the surface it makes sense, I'll take a closer look soon. |
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.
Add two commands: 1. `tufaceous archive`, which archives a repository into a zip file. 2. `tufaceous extract`, which extracts a repository from a zip file. The main reason is that zip supports random access to files and tar does not. I was hoping to just be able to read the repository out of the zip file from memory, but I ran into awslabs/tough#563 while implementing it. Once that is resolved (or we write our own TUF crate) it should be possible to do that. Regardless, I don't want to foreclose that option forever, so let's just use zip for now rather than having to deal with a migration in the future. Pull Request: oxidecomputer#2266
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.
This seems good!
@sunshowers You mentioned this is a breaking change because of the read_target
signature change? That's because of the anonymous lifetime?
@zmrow Yes -- the
Those users will now have to rearrange their code so that the repository stays open longer than any of the readers. |
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.
Thanks!
Add two commands: 1. `tufaceous archive`, which archives a repository into a zip file. 2. `tufaceous extract`, which extracts a repository from a zip file. ## Why zip and not tar? The main reason is that zip supports random access to files and tar does not. I was hoping to just be able to read the repository out of the zip file from memory, but I ran into awslabs/tough#563 while implementing it. Once that is resolved (or we write our own TUF crate) it should be possible to do that. Regardless, I don't want to foreclose that option forever, so let's just use zip for now rather than having to deal with a migration in the future. Depends on #2300.
Looking for feedback on this one -- is this desirable?
Issue #, if available:
Description of changes:
Add a lifetime parameter to
Transport::fetch
andRepository::read_target
.This is useful in cases where you're implementing a transport that borrows from the reader (e.g. if you're reading a TUF repository from a zip file, returning a
ZipFile<'a>
as the transport).This is a breaking change because
read_target
now borrows fromself
. I don't think that's a major issue, because in most cases you're going to keep theRepository
open for longer than any of the targets you read from it.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.