[][src]Struct egg_mode::Response

pub struct Response<T> {
    pub rate_limit: i32,
    pub rate_limit_remaining: i32,
    pub rate_limit_reset: i32,
    pub response: T,
}

A helper struct to wrap response data with accompanying rate limit information.

This is returned by any function that calls a rate-limited method on Twitter, to allow for inline checking of the rate-limit information without an extra call to service::rate_limit_info.

As this implements Deref and DerefMut, you can transparently use the contained response's methods as if they were methods on this struct.

Fields

rate_limit: i32

The rate limit ceiling for the given request.

rate_limit_remaining: i32

The number of requests left for the 15-minute window.

rate_limit_reset: i32

The UTC Unix timestamp at which the rate window resets.

response: T

The decoded response from the request.

Methods

impl<T> Response<T>[src]

pub fn map<F, U>(src: Response<T>, fun: F) -> Response<U> where
    F: FnOnce(T) -> U, 
[src]

Convert a Response<T> to a Response<U> by running its contained response through the given function. This preserves its rate-limit information.

Note that this is not a member function, so as to not conflict with potential methods on the contained T.

impl<T> Response<Vec<T>>[src]

Important traits for ResponseIterRef<'a, T>
pub fn iter(&self) -> ResponseIterRef<T>[src]

Returns an iterator that yields references into the returned collection, alongside rate-limit information for the whole method call.

Important traits for ResponseIterMut<'a, T>
pub fn iter_mut(&mut self) -> ResponseIterMut<T>[src]

Returns an iterator that yields mutable references into the returned collection, alongside rate-limit information for the whole method call.

Trait Implementations

impl<'a, T> IntoIterator for &'a Response<Vec<T>> where
    T: 'a, 
[src]

Iteration over a response that returned a collection, while leaving the response in place.

type Item = Response<&'a T>

The type of the elements being iterated over.

type IntoIter = ResponseIterRef<'a, T>

Which kind of iterator are we turning this into?

impl<'a, T> IntoIterator for &'a mut Response<Vec<T>> where
    T: 'a, 
[src]

Mutable iteration over a response that returned a collection, while leaving the response in place.

type Item = Response<&'a mut T>

The type of the elements being iterated over.

type IntoIter = ResponseIterMut<'a, T>

Which kind of iterator are we turning this into?

impl<T> IntoIterator for Response<Vec<T>>[src]

Iteration over a response that returned a collection, copying the rate limit information across all values.

type Item = Response<T>

The type of the elements being iterated over.

type IntoIter = ResponseIter<T>

Which kind of iterator are we turning this into?

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

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

type Target = T

The resulting type after dereferencing.

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

impl<T> FromIterator<Response<T>> for Response<Vec<T>>[src]

FromIterator impl that allows collecting several responses into one, preserving the latest rate limit information.

impl<'de, T> Deserialize<'de> for Response<T> where
    T: Deserialize<'de>,
    T: Default
[src]

Auto Trait Implementations

impl<T> Send for Response<T> where
    T: Send

impl<T> Sync for Response<T> where
    T: Sync

Blanket Implementations

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

impl<T> From<T> for T[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> 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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

impl<T> Erased for T

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self