pub enum Length {
Show 13 variants
Points(f32),
Percent(f32),
ViewportWidth(f32),
ViewportHeight(f32),
Add(Box<Length>, Box<Length>),
Subtract(Box<Length>, Box<Length>),
Min(Vec<Length>),
Max(Vec<Length>),
Clamp {
min: Box<Length>,
preferred: Box<Length>,
max: Box<Length>,
},
FitContent(Option<Box<Length>>),
MinContent,
MaxContent,
Auto,
}Expand description
A declarative layout length resolved by the constraint engine.
Variants§
Points(f32)
Fixed logical points.
Percent(f32)
Percentage of the containing axis. 50.0 means 50%, not 0.5.
ViewportWidth(f32)
Percentage of the active viewport width. 100.0 means full viewport width.
ViewportHeight(f32)
Percentage of the active viewport height. 100.0 means full viewport height.
Add(Box<Length>, Box<Length>)
Sum of two length expressions.
Subtract(Box<Length>, Box<Length>)
Difference between two length expressions.
Min(Vec<Length>)
Smallest value from a list of fully resolvable length expressions.
Max(Vec<Length>)
Largest value from a list of fully resolvable length expressions.
Clamp
Preferred value clamped between lower and upper bounds.
Fields
FitContent(Option<Box<Length>>)
Size to intrinsic content, optionally capped by a limit.
MinContent
Minimum intrinsic size required by the content.
MaxContent
Preferred intrinsic size of the content without wrapping.
Auto
Let the active layout algorithm choose the size.
Implementations§
Source§impl Length
impl Length
Sourcepub fn clamp(min: Length, preferred: Length, max: Length) -> Length
pub fn clamp(min: Length, preferred: Length, max: Length) -> Length
Clamps a preferred length between lower and upper bounds.
Sourcepub fn min(values: impl Into<Vec<Length>>) -> Length
pub fn min(values: impl Into<Vec<Length>>) -> Length
Selects the smallest fully resolved length.
Sourcepub fn max(values: impl Into<Vec<Length>>) -> Length
pub fn max(values: impl Into<Vec<Length>>) -> Length
Selects the largest fully resolved length.
Sourcepub fn fit_content(limit: impl Into<Option<Length>>) -> Length
pub fn fit_content(limit: impl Into<Option<Length>>) -> Length
Sizes to content, optionally capped by a resolved limit.
Sourcepub fn all(value: Length) -> [Length; 4]
pub fn all(value: Length) -> [Length; 4]
Creates [left, right, top, bottom] edges with one shared value.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Length
impl<'de> Deserialize<'de> for Length
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Length, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Length, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Length
impl Serialize for Length
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Length
Auto Trait Implementations§
impl Freeze for Length
impl RefUnwindSafe for Length
impl Send for Length
impl Sync for Length
impl Unpin for Length
impl UnsafeUnpin for Length
impl UnwindSafe for Length
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.