Skip to main content

QueryCondition

Trait QueryCondition 

Source
pub trait QueryCondition: Sized + ToCss {
    type Feature;

Show 15 methods // Required methods fn parse_feature(input: &mut Parser<'_>) -> Result<Self>; fn parse_style_query(input: &mut Parser<'_>) -> Result<Self>; fn needs_parens( &self, parent_operator: Option<Operator>, targets: &Targets, ) -> bool; fn as_feature(&self) -> Option<&Self::Feature>; fn as_not(&self) -> Option<&Self>; fn as_operation(&self) -> Option<(Operator, &[Self])>; fn feature_to_css( f: &Self::Feature, dest: &mut Printer<'_>, ) -> Result<(), PrintErr>; // Provided methods fn parse_feature_with_options( input: &mut Parser<'_>, _options: &ParserOptions<'_>, ) -> Result<Self> { ... } fn create_negation(condition: Box<Self>) -> Self { ... } fn create_negation_in(condition: Self, _alloc: ArenaPtr) -> Self { ... } fn create_operation(operator: Operator, conditions: Vec<Self>) -> Self { ... } fn create_operation_in( operator: Operator, conditions: ArenaVec<Self>, ) -> Self { ... } fn parse_style_query_with_options( input: &mut Parser<'_>, _options: &ParserOptions<'_>, ) -> Result<Self> { ... } fn extra_to_css(&self, _dest: &mut Printer<'_>) -> Result<(), PrintErr> { ... } fn condition_to_css(&self, dest: &mut Printer<'_>) -> Result<(), PrintErr> { ... }
}
Expand description

Trait modeling Zig’s ValidQueryCondition comptime interface check. Any type that can appear as a node in a query-condition tree.

Required Associated Types§

Source

type Feature

Leaf payload: QueryFeature<_> for media/container, Property for StyleQuery.

Required Methods§

Source

fn parse_feature(input: &mut Parser<'_>) -> Result<Self>

Source

fn parse_style_query(input: &mut Parser<'_>) -> Result<Self>

Source

fn needs_parens( &self, parent_operator: Option<Operator>, targets: &Targets, ) -> bool

Source

fn as_feature(&self) -> Option<&Self::Feature>

Source

fn as_not(&self) -> Option<&Self>

Source

fn as_operation(&self) -> Option<(Operator, &[Self])>

Source

fn feature_to_css( f: &Self::Feature, dest: &mut Printer<'_>, ) -> Result<(), PrintErr>

Serialize the leaf feature. Not defaulted: Property::to_css takes an extra is_custom_property flag, and QueryFeature::to_css is inherent (not the ToCss trait), so callers must spell the dispatch.

Provided Methods§

Source

fn parse_feature_with_options( input: &mut Parser<'_>, _options: &ParserOptions<'_>, ) -> Result<Self>

parse_feature with ParserOptions threaded — needed for the env() arm of MediaFeatureValue::parse_unknown. Default impl drops options so out-of-tree implementors (e.g. rules::container::{ContainerCondition,StyleQuery}) keep compiling until they opt in.

Source

fn create_negation(condition: Box<Self>) -> Self

Source

fn create_negation_in(condition: Self, _alloc: ArenaPtr) -> Self

Source

fn create_operation(operator: Operator, conditions: Vec<Self>) -> Self

Source

fn create_operation_in(operator: Operator, conditions: ArenaVec<Self>) -> Self

Source

fn parse_style_query_with_options( input: &mut Parser<'_>, _options: &ParserOptions<'_>, ) -> Result<Self>

See parse_feature_with_options — same default-forward rationale.

Source

fn extra_to_css(&self, _dest: &mut Printer<'_>) -> Result<(), PrintErr>

Serialize a variant that isn’t Feature/Not/Operation (e.g. ContainerCondition::Style). Implementors with no extra variants leave the default.

Source

fn condition_to_css(&self, dest: &mut Printer<'_>) -> Result<(), PrintErr>

Provided: shared ToCss body for the Feature/Not/Operation lattice (+ extra_to_css fallback). Mirrors the three hand-rolled matches this replaced.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§