pub struct Lease<T> { /* private fields */ }Expand description
A handle to a leasable value.
Use poll_acquire to acquire the lease, take to grab the leased value, and restore to
return the leased value when you’re done with it.
The code will panic if you attempt to access the S behind a Lease through Deref or
DerefMut without having acquired the lease through poll_acquire first, or if you have
called take.
The code will also panic if you attempt to drop a Lease without first restoring the leased
value.
Implementations§
Source§impl<T> Lease<T>
impl<T> Lease<T>
Sourcepub fn poll_acquire(&mut self) -> Async<()>
pub fn poll_acquire(&mut self) -> Async<()>
Try to acquire the lease.
If the lease is not available, the current task is notified once it is.
Sourcepub fn release(&mut self)
pub fn release(&mut self)
Release the lease (if it has been acquired).
This provides a way of “undoing” a call to poll_ready should you decide you don’t need
the lease after all, or if you only needed access by reference.
This method will panic if you attempt to release the lease after you have called take.
Sourcepub fn transfer(&mut self) -> Self
pub fn transfer(&mut self) -> Self
Leave behind a non-acquired lease in place of this one, and return this acquired lease.
This allows you to move a previously acquired lease into another context (like a Future)
where you will later restore the leased value.
This method will panic if you attempt to call it without first having acquired the lease.
Sourcepub fn take(&mut self) -> T
pub fn take(&mut self) -> T
Take the leased value.
This method will panic if you attempt to call it without first having acquired the lease.
Note that you must call restore on this lease before you drop it to return the leased
value to other waiting clients. If you do not, dropping the lease will panic.