Struct components::Units[][src]

pub struct Units(_);

Implementations

impl Units[src]

pub fn get_unit_type(&self) -> UnitType[src]

Retrieves the unit type of the value stored inside self

Returns

a unit type

pub fn get_unit_value(&self) -> f32[src]

Retrieves the value stored inside self

Returns

the value stored inside a Units

pub fn to_pixels(&mut self) -> f32[src]

Converts a value in Units to pixels

Returns

the value in pixels

pub fn from_cm(cm: f32) -> Units[src]

Stores a value in centimeters inside units

units

a Units

cm

centimeters

pub fn from_em(em: f32) -> Units[src]

Stores a value in em inside units, using the default font name as returned by Backend::get_font_name

units

a Units

em

em

pub fn from_em_for_font(font_name: Option<&str>, em: f32) -> Units[src]

Stores a value in em inside units using font_name

units

a Units

font_name

the font name and size

em

em

pub fn from_mm(mm: f32) -> Units[src]

Stores a value in millimiters inside units

units

a Units

mm

millimeters

pub fn from_pixels(px: i32) -> Units[src]

Stores a value in pixels inside units

units

a Units

px

pixels

pub fn from_pt(pt: f32) -> Units[src]

Stores a value in typographic points inside units

units

a Units

pt

typographic points

pub fn from_string(str: &str) -> Option<Units>[src]

Parses a value and updates units with it

A Units expressed in string should match:

  units: wsp* unit-value wsp* unit-name? wsp*
  unit-value: number
  unit-name: 'px' | 'pt' | 'mm' | 'em' | 'cm'
  number: digit+
          | digit* sep digit+
  sep: '.' | ','
  digit: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
  wsp: (#0x20 | #0x9 | #0xA | #0xB | #0xC | #0xD)+

For instance, these are valid strings:

  10 px
  5.1 em
  24 pt
  12.6 mm
  .3 cm

While these are not:

  42 cats
  omg!1!ponies

If no unit is specified, pixels are assumed.

units

a Units

str

the string to convert

Returns

true if the string was successfully parsed, and false otherwise

Trait Implementations

impl Clone for Units[src]

impl Debug for Units[src]

impl Display for Units[src]

impl Eq for Units[src]

impl Hash for Units[src]

impl Ord for Units[src]

impl PartialEq<Units> for Units[src]

impl PartialOrd<Units> for Units[src]

impl StaticType for Units[src]

impl StructuralEq for Units[src]

impl StructuralPartialEq for Units[src]

Auto Trait Implementations

impl RefUnwindSafe for Units

impl !Send for Units

impl !Sync for Units

impl Unpin for Units

impl UnwindSafe for Units

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

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

impl<Fr, To> IntoColor<To> for Fr where
    To: FromColor<Fr>, 

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToSendValue for T where
    T: SetValue + Send + ToValue + ?Sized
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized
[src]

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<V, T> VZip<V> for T where
    V: MultiLane<T>,