[][src]Struct async_lease::Lease

pub struct Lease<T> { /* fields omitted */ }

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) -> Async<()>[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> From<T> for Lease<T>[src]

impl<T> Drop for Lease<T>[src]

impl<T> Send for Lease<T> where
    T: Send
[src]

impl<T> Default for Lease<T> where
    T: Default
[src]

impl<T> Clone for Lease<T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for Lease<T>[src]

impl<T> Deref for Lease<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for Lease<T>[src]

Auto Trait Implementations

impl<T> !Sync for Lease<T>

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]