Struct app_units::Au

source ·
#[repr(transparent)]
pub struct Au(pub i32);
Expand description

An App Unit, the fundamental unit of length in Servo. Usually 1/60th of a pixel (see AU_PER_PX)

Please ensure that the values are between MIN_AU and MAX_AU. It is safe to construct invalid Au values, but it may lead to panics and overflows.

Tuple Fields§

§0: i32

Implementations§

source§

impl Au

source

pub fn new(value: i32) -> Au

FIXME(pcwalton): Workaround for lack of cross crate inlining of newtype structs!

source

pub fn scale_by(self, factor: f32) -> Au

source

pub fn scale_by_trunc(self, factor: f32) -> Au

Scale, but truncate (useful for viewport-relative units)

source

pub fn from_f64_au(float: f64) -> Self

source

pub fn from_px(px: i32) -> Au

source

pub fn to_px(self) -> i32

Round this app unit down to the pixel towards zero and return it.

source

pub fn ceil_to_px(self) -> i32

Ceil this app unit to the appropriate pixel boundary and return it.

source

pub fn to_nearest_px(self) -> i32

source

pub fn to_nearest_pixel(self, pixels_per_px: f32) -> f32

source

pub fn to_f32_px(self) -> f32

source

pub fn to_f64_px(self) -> f64

source

pub fn from_f32_px(px: f32) -> Au

source

pub fn from_f64_px(px: f64) -> Au

source

pub fn abs(self) -> Self

source

pub fn max_assign(&mut self, other: Self)

source

pub fn min_assign(&mut self, other: Self)

Trait Implementations§

source§

impl Add for Au

§

type Output = Au

The resulting type after applying the + operator.
source§

fn add(self, other: Au) -> Au

Performs the + operation. Read more
source§

impl AddAssign for Au

source§

fn add_assign(&mut self, other: Au)

Performs the += operation. Read more
source§

impl Clone for Au

source§

fn clone(&self) -> Au

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Au

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Au

source§

fn default() -> Au

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Au

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Au, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl Div<i32> for Au

§

type Output = Au

The resulting type after applying the / operator.
source§

fn div(self, other: i32) -> Au

Performs the / operation. Read more
source§

impl Div for Au

§

type Output = i32

The resulting type after applying the / operator.
source§

fn div(self, other: Au) -> i32

Performs the / operation. Read more
source§

impl DivAssign<i32> for Au

source§

fn div_assign(&mut self, other: i32)

Performs the /= operation. Read more
source§

impl Hash for Au

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Mul<Au> for i32

§

type Output = Au

The resulting type after applying the * operator.
source§

fn mul(self, other: Au) -> Au

Performs the * operation. Read more
source§

impl Mul<i32> for Au

§

type Output = Au

The resulting type after applying the * operator.
source§

fn mul(self, other: i32) -> Au

Performs the * operation. Read more
source§

impl MulAssign<i32> for Au

source§

fn mul_assign(&mut self, other: i32)

Performs the *= operation. Read more
source§

impl Neg for Au

§

type Output = Au

The resulting type after applying the - operator.
source§

fn neg(self) -> Au

Performs the unary - operation. Read more
source§

impl Ord for Au

source§

fn cmp(&self, other: &Au) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Au

source§

fn eq(&self, other: &Au) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Au

source§

fn partial_cmp(&self, other: &Au) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Rem<i32> for Au

§

type Output = Au

The resulting type after applying the % operator.
source§

fn rem(self, other: i32) -> Au

Performs the % operation. Read more
source§

impl Rem for Au

§

type Output = Au

The resulting type after applying the % operator.
source§

fn rem(self, other: Au) -> Au

Performs the % operation. Read more
source§

impl Serialize for Au

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub for Au

§

type Output = Au

The resulting type after applying the - operator.
source§

fn sub(self, other: Au) -> Au

Performs the - operation. Read more
source§

impl SubAssign for Au

source§

fn sub_assign(&mut self, other: Au)

Performs the -= operation. Read more
source§

impl<'a> Sum<&'a Au> for Au

source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Sum for Au

source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Zero for Au

source§

fn zero() -> Au

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl Copy for Au

source§

impl Eq for Au

source§

impl StructuralPartialEq for Au

Auto Trait Implementations§

§

impl Freeze for Au

§

impl RefUnwindSafe for Au

§

impl Send for Au

§

impl Sync for Au

§

impl Unpin for Au

§

impl UnwindSafe for Au

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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