[][src]Struct cursive::view::SizeCache

pub struct SizeCache<T = ()> {
    pub value: usize,
    pub constrained: bool,
    pub extra: T,
}

Cache around a one-dimensional layout result.

This is not a View, but something to help you if you create your own Views.

Fields

value: usize

Cached value

constrained: bool

true if the last size was constrained.

If unconstrained, any request larger than this value would return the same size.

extra: T

Extra field.

Implementations

impl SizeCache<()>[src]

pub fn new(value: usize, constrained: bool) -> SizeCache<()>[src]

Creates a new sized cache

pub fn build(size: XY<usize>, req: XY<usize>) -> XY<SizeCache<()>>[src]

Creates a new bi-dimensional cache.

It will stay valid for the same request, and compatible ones.

A compatible request is one where, for each axis, either:

  • the request is equal to the cached size, or
  • the request is larger than the cached size and the cache is unconstrained

Notes:

  • size must fit inside req.
  • for each dimension, constrained = (size == req)

impl<T> SizeCache<T>[src]

pub fn new_extra(value: usize, constrained: bool, extra: T) -> SizeCache<T>[src]

Creates a new sized cache

pub fn build_extra(
    size: XY<usize>,
    req: XY<usize>,
    extra: XY<T>
) -> XY<SizeCache<T>>
[src]

Creates a new bi-dimensional cache.

Similar to build(), but includes the extra field.

pub fn accept(self, request: usize) -> bool[src]

Returns true if self is still valid for the given request.

pub fn value(self) -> usize[src]

Returns the value in the cache.

Trait Implementations

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

impl<T> Copy for SizeCache<T> where
    T: Copy
[src]

impl<T> Debug for SizeCache<T> where
    T: Debug
[src]

impl<T> PartialEq<SizeCache<T>> for SizeCache<T> where
    T: PartialEq<T>, 
[src]

impl<T> StructuralPartialEq for SizeCache<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for SizeCache<T> where
    T: RefUnwindSafe
[src]

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

impl<T> Sync for SizeCache<T> where
    T: Sync
[src]

impl<T> Unpin for SizeCache<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for SizeCache<T> where
    T: UnwindSafe
[src]

Blanket Implementations

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

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

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

impl<T> Erased for T

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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> With for T[src]