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 lifetimes #272

Merged
merged 12 commits into from
Feb 21, 2021
Merged

Fix lifetimes #272

merged 12 commits into from
Feb 21, 2021

Conversation

elihunter173
Copy link
Contributor

@elihunter173 elihunter173 commented Feb 17, 2021

What did you implement:

After a dance with borrowck, I updated the lifetimes of problematic methods in lib.rs where the return's lifetime was unnecessarily tied to some of the inputs. In particular, {Containers, Images, Networks, Services, Volumes}::get() now return a {Container, Image, Network, Service, Volume} which is tied to the lifetime of the Docker they container rather than the lifetime of the {Containers, ...} which created them. This means we no longer have to create unnecessary locals such as images in the following code to avoid the compiler complaining about temporary value dropped while borrowed

let images = docker.images();
let mut stream = images.build(&options);

Instead, we can write the following as you would intuitively expect to work.

let mut stream = docker.images().build(&options);

Various other methods were also fixed. Generally, anything that returned a stream is now exclusively tied to the lifetime of the Docker used to create them (or Transport for transport.rs) rather than the lifetime of both the Docker and whatever they use as input (e.g. ExecOptions for Container::exec()).

Further, I renamed lifetimes from 'a to 'docker and made some lifetimes explicit to make the code easier to read and understand.

Closes: #271

How did you verify your change:

Ran unit tests.

What (if anything) would need to be called out in the CHANGELOG for the next release:

This should be backwards compatible because in every case I made the lifetimes less restrictive. Nevertheless, I updated the changelog to mention it.

@thomaseizinger
Copy link
Contributor

Thank you!

This also fixes a bug where it was impossible to return the Stream returned from logs() due to lifetime issues!

bors bot added a commit to testcontainers/testcontainers-rs that referenced this pull request Feb 19, 2021
261: Upgrade default bitcoin image version to 0.21.0 r=bonomat a=bonomat

With the upgrade to 0.21.0 a new startup command was introduced which allows us to execute a script when the startup sequence was completed. We simply echo `bitcoind startup sequence completed.`.
This allows us to remove `-debug` which keeps the bitcoind log _clean_.
Note: this release also removed the default wallet.


268: Introduce async docker interface and shiplift-backed implementation r=thomaseizinger a=thomaseizinger

Blocked by:

- [ ] : softprops/shiplift#272
- [ ] : Shiplift release
- [x] : #264
- [x] : Open TODOs (see comments)

Co-authored-by: Philipp Hoenisch <[email protected]>
Co-authored-by: walterh <[email protected]>
Co-authored-by: Thomas Eizinger <[email protected]>
@softprops softprops merged commit 9c72d3a into softprops:master Feb 21, 2021
elihunter173 added a commit to elihunter173/shiplift that referenced this pull request Mar 7, 2021
@elihunter173 elihunter173 deleted the fix-lifetimes branch March 9, 2021 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Liftimes for various methods incorrect
3 participants