use std::str::FromStr;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Layout {
Fill,
Responsive,
Intrinsic,
Fixed,
#[default]
Auto,
Stretch,
ScaleDown,
}
impl Layout {
pub fn as_str(&self) -> &'static str {
match self {
Layout::Fill => "fill",
Layout::Responsive => "responsive",
Layout::Intrinsic => "intrinsic",
Layout::Fixed => "fixed",
Layout::Auto => "auto",
Layout::Stretch => "stretch",
Layout::ScaleDown => "scale-down",
}
}
}
impl FromStr for Layout {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"fill" => Ok(Layout::Fill),
"responsive" => Ok(Layout::Responsive),
"intrinsic" => Ok(Layout::Intrinsic),
"fixed" => Ok(Layout::Fixed),
"auto" => Ok(Layout::Auto),
"stretch" => Ok(Layout::Stretch),
"scale-down" => Ok(Layout::ScaleDown),
_ => Err(()),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Decoding {
#[default]
Auto,
Sync,
Async,
}
impl Decoding {
pub fn as_str(&self) -> &'static str {
match self {
Decoding::Auto => "auto",
Decoding::Sync => "sync",
Decoding::Async => "async",
}
}
}
impl FromStr for Decoding {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"auto" => Ok(Decoding::Auto),
"sync" => Ok(Decoding::Sync),
"async" => Ok(Decoding::Async),
_ => Err(()),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Position {
#[default]
Center,
Top,
Bottom,
Left,
Right,
TopLeft,
TopRight,
BottomLeft,
BottomRight,
}
impl Position {
pub fn as_str(&self) -> &'static str {
match self {
Position::Center => "center",
Position::Top => "top",
Position::Bottom => "bottom",
Position::Left => "left",
Position::Right => "right",
Position::TopLeft => "top left",
Position::TopRight => "top right",
Position::BottomLeft => "bottom left",
Position::BottomRight => "bottom right",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ObjectFit {
Fill,
#[default]
Contain,
Cover,
ScaleDown,
None,
}
impl ObjectFit {
pub fn as_str(&self) -> &'static str {
match self {
ObjectFit::Fill => "fill",
ObjectFit::Contain => "contain",
ObjectFit::Cover => "cover",
ObjectFit::ScaleDown => "scale-down",
ObjectFit::None => "none",
}
}
}
#[derive(Clone, PartialEq, Default)]
pub enum CrossOrigin {
Anonymous,
UseCredentials,
#[default]
None,
}
impl CrossOrigin {
pub fn as_str(&self) -> Option<&'static str> {
match self {
CrossOrigin::Anonymous => Some("anonymous"),
CrossOrigin::UseCredentials => Some("use-credentials"),
CrossOrigin::None => None,
}
}
}
#[derive(Clone, PartialEq, Default)]
pub enum FetchPriority {
High,
Low,
#[default]
Auto,
}
impl FetchPriority {
pub fn as_str(&self) -> &'static str {
match self {
FetchPriority::High => "high",
FetchPriority::Low => "low",
FetchPriority::Auto => "auto",
}
}
}
#[derive(Clone, PartialEq, Default)]
pub enum Loading {
Eager,
Lazy,
#[default]
Auto,
}
impl Loading {
pub fn as_str(&self) -> &'static str {
match self {
Loading::Eager => "eager",
Loading::Lazy => "lazy",
Loading::Auto => "auto",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ReferrerPolicy {
NoReferrer,
NoReferrerWhenDowngrade,
Origin,
OriginWhenCrossOrigin,
SameOrigin,
StrictOrigin,
#[default]
StrictOriginWhenCrossOrigin,
UnsafeUrl,
}
impl ReferrerPolicy {
pub fn as_str(&self) -> &'static str {
match self {
ReferrerPolicy::NoReferrer => "no-referrer",
ReferrerPolicy::NoReferrerWhenDowngrade => "no-referrer-when-downgrade",
ReferrerPolicy::Origin => "origin",
ReferrerPolicy::OriginWhenCrossOrigin => "origin-when-cross-origin",
ReferrerPolicy::SameOrigin => "same-origin",
ReferrerPolicy::StrictOrigin => "strict-origin",
ReferrerPolicy::StrictOriginWhenCrossOrigin => "strict-origin-when-cross-origin",
ReferrerPolicy::UnsafeUrl => "unsafe-url",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum AriaLive {
#[default]
Off,
Polite,
Assertive,
}
impl AriaLive {
pub fn as_str(&self) -> &'static str {
match self {
AriaLive::Off => "off",
AriaLive::Polite => "polite",
AriaLive::Assertive => "assertive",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum AriaPressed {
True,
False,
Mixed,
#[default]
Undefined,
}
impl AriaPressed {
pub fn as_str(&self) -> &'static str {
match self {
AriaPressed::True => "true",
AriaPressed::False => "false",
AriaPressed::Mixed => "mixed",
AriaPressed::Undefined => "undefined",
}
}
}