[−][src]Struct async_lease::Lease
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.
Methods
impl<T> Lease<T>
[src]
pub fn poll_acquire(&mut self, cx: &mut Context) -> Poll<()>
[src]
Try to acquire the lease.
If the lease is not available, the current task is notified once it is.
pub fn release(&mut self)
[src]
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
.
pub fn transfer(&mut self) -> Self
[src]
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.
pub fn take(&mut self) -> T
[src]
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.
pub fn restore(&mut self, state: T)
[src]
Restore the leased value.
This method will panic if you attempt to call it without first having acquired the lease.
Note that once you return the leased value, the lease is no longer considered acquired.
Trait Implementations
impl<T> Send for Lease<T> where
T: Send,
[src]
T: Send,
impl<T> Drop for Lease<T>
[src]
impl<T> From<T> for Lease<T>
[src]
impl<T> Clone for Lease<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Default for Lease<T> where
T: Default,
[src]
T: Default,
impl<T: Debug> Debug for Lease<T>
[src]
impl<T> Deref for Lease<T>
[src]
impl<T> DerefMut for Lease<T>
[src]
Auto Trait Implementations
impl<T> !Sync for Lease<T>
impl<T> Unpin for Lease<T>
impl<T> !UnwindSafe for Lease<T>
impl<T> !RefUnwindSafe for Lease<T>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,