Trait Filter

Source
pub trait Filter: 'static {
    type All: Components;
    type Any: Components;
    type None: Components;
    type Exact: Components;
}
Expand description

A trait for selecting certain entities that meet All, Any, and None conditions.

§Example


#[derive(Component)] struct Ca;
#[derive(Component)] struct Cb;
#[derive(Component)] struct Cc;
#[derive(Component)] struct Cd;

/// Filtering using All, Any, and None.
struct Fa;
impl Filter for Fa {
    type All = Ca;
    type Any = (Cb, Cc);
    type None = Cd;
    type Exact = ();
}

// Or simply
filter!(Fb, All = Ca, Any = (Cb, Cc));

/// Filtering using Exact.
struct Fb;
impl Filter for Fc {
    type All = ();
    type Any = ();
    type None = ();
    type Exact = (Ca, Cb);
}

// Or simply
filter!(Fd, Exact = (Ca, Cb));

Required Associated Types§

Source

type All: Components

A Component group to select entities that contains all components in this group. It’s something like AND condition. But if All is empty, then any entities won’t be rejected.

Source

type Any: Components

A Component group to select entities that contains any components in this group. It’s something like OR condition. But if Any is empty, then any entities won’t be rejected.

Source

type None: Components

A Component group to select entities that don’t contain any components in this group. It’s something like NOR condition. Buf if None is empty, then any entities won’t be rejected.

Source

type Exact: Components

A Component group to select a specific entity that consists of components in this group exactly.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Entity> Filter for T

An Entity is an exact Filter.