[][src]Struct nines::ValidDimensions

pub struct ValidDimensions<S: Scalar>(_);

Slice dimensions with non-negative & non-NAN dimensions (including borders.)

Do not base soundness assumptions on this definition of validity - debug_assert_valid can bypass checks.

Methods

impl<S: Scalar> ValidDimensions<S>[src]

#[must_use] pub fn outer(&self) -> ValidRect<S>[src]

#[must_use] pub fn inner(&self) -> ValidRect<S>[src]

#[must_use] pub fn borders(&self) -> Rect<S>[src]

Get the sizes of the borders - that is, the spacing between the outer and inner rects.

 left   right
 ┊←→┊    ┊←→┊
 ┊  ┊    ┊  ┊
 ┌──┬────┬──┐┈┈
 │  │    │  │ ↕ top
 ├──┼────┼──┤┈┈
 │  │    │  │
 │  │    │  │
 ├──┼────┼──┤┈┈
 │  │    │  │ ↕ bottom
 └──┴────┴──┘┈┈

#[must_use] pub fn with_outer(&self, outer: impl Into<ValidRect<S>>) -> Result<Self, Error>[src]

Create a new 9-slice with specified outer dimensions, keeping the border sizes the same.

Can return Err if:

  • rect is invalid
  • The center would have negative bounds

May panic on overflow/underflow.

#[must_use] pub fn with_inner(&self, inner: impl Into<ValidRect<S>>) -> Self[src]

Create a new 9-slice with specified inner dimensions, keeping the border sizes the same.

May panic on overflow/underflow.

Methods from Deref<Target = Dimensions<S>>

#[must_use] pub fn validate(&self) -> Result<ValidDimensions<S>, Error>[src]

Validate these dimensions are non-negative / non-NaN. This means:

outer.left ≤ inner.left ≤ inner.right ≤ outer.right
outer.top ≤ inner.top ≤ inner.bottom ≤ outer.bottom

Trait Implementations

impl<S: Clone + Scalar> Clone for ValidDimensions<S>[src]

impl<S: Copy + Scalar> Copy for ValidDimensions<S>[src]

impl<S: Default + Scalar> Default for ValidDimensions<S>[src]

impl<S: Scalar> PartialEq<ValidDimensions<S>> for ValidDimensions<S>[src]

impl<S: Scalar> PartialEq<Dimensions<S>> for ValidDimensions<S>[src]

impl<S: Scalar> PartialEq<ValidDimensions<S>> for Dimensions<S>[src]

impl<S: Scalar> Deref for ValidDimensions<S>[src]

type Target = Dimensions<S>

The resulting type after dereferencing.

impl<S: Debug + Scalar> Debug for ValidDimensions<S>[src]

impl<S: Scalar> TryFrom<Dimensions<S>> for ValidDimensions<S>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'_, S: Scalar> TryFrom<&'_ Dimensions<S>> for ValidDimensions<S>[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<S> Send for ValidDimensions<S> where
    S: Send

impl<S> Sync for ValidDimensions<S> where
    S: Sync

impl<S> Unpin for ValidDimensions<S> where
    S: Unpin

impl<S> UnwindSafe for ValidDimensions<S> where
    S: UnwindSafe

impl<S> RefUnwindSafe for ValidDimensions<S> where
    S: RefUnwindSafe

Blanket Implementations

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 = !

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> Borrow<T> for T where
    T: ?Sized
[src]

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

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