Skip to main content

Target

Struct Target 

Source
pub struct Target {
    pub name: String,
    /* private fields */
}
Expand description

A writer’s declaration of what it accepts.

Fields§

§name: String

Implementations§

Source§

impl Target

Source

pub fn new(name: impl Into<String>) -> Self

Source

pub fn rule(self, name: &str, legality: Legality) -> Self

Source

pub fn legal(self, name: &str) -> Self

Source

pub fn illegal(self, name: &str) -> Self

Source

pub fn dynamic( self, name: &str, check: impl Fn(&World, Entity) -> bool + Send + Sync + 'static, ) -> Self

Source

pub fn covered( self, name: &str, what: &str, check: fn(&World, Entity) -> bool, ) -> Self

A name the writer writes through another component: legal on the entities check accepts, what naming the cover ("covered by <dialect>.light"); the rest are reported as <name> not <what> (Legality::Covered).

Source

pub fn dynamic_typed<T: Component>( self, check: impl Fn(&T) -> bool + Send + Sync + 'static, ) -> Self

The legal checks of a typed component: legal when check accepts the value.

Source

pub fn check<T: Component>( self, what: &str, check: impl Fn(&T) -> bool + Send + Sync + 'static, ) -> Self

A named value rule on a typed component: as Target::dynamic_typed, with what naming the rule in errors (“every placement regular”).

Source

pub fn check_resource<R: Resource>( self, what: &str, check: impl Fn(&R) -> bool + Send + Sync + 'static, ) -> Self

A named value rule on a resource: the target refuses the world while the resource is there and check refuses it ("every surface classified"). A pass of the stated pipeline that modifies or removes the resource fixes it.

Source

pub fn rule_words(&self, name: &str) -> Option<&str>

The words naming the value rule on name (a component’s Target::check, a covered name’s cover (Target::covered) or a resource’s Target::check_resource), if it has a named one.

Source

pub fn refused_resources(&self, w: &World) -> Vec<&str>

The resources of w whose value rule refuses them, by name.

Source

pub fn legality(&self, name: &str) -> Option<&Legality>

Source

pub fn rules(&self) -> Vec<(&str, Rule)>

Every name the target states a rule for, with the rule’s kind (its checks left out): what a coverage report lists of the writer.

Source

pub fn checked_resources(&self) -> Vec<&str>

The resources it checks the values of (Target::check_resource), by name.

Source

pub fn check_prepared(&self, w: &World) -> Prepared

Check a prepared world against the target without changing it: what the writer won’t write (an illegal or an unlisted name, and a covered name’s uncovered entities: Prepared::unsupported, entity counts by name; a resource it neither lists nor rules on: Prepared::unsupported_resources; the conversion’s own resources, crate::convert::OPERATIONAL_RESOURCES, aside), and values of names it writes that its value rule refuses (Prepared::invalid, by name with the rule’s words) or resources it refuses (Prepared::invalid_resources). A resource is listed like a component (Target::legal, Target::illegal).

Source

pub fn illegal_entities(&self, w: &World, name: &str, mode: Mode) -> Vec<Entity>

Entities whose name component the target does not accept as it is (all of them for an illegal name).

Trait Implementations§

Source§

impl Clone for Target

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Target

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Target

§

impl !UnwindSafe for Target

§

impl Forget for Target

§

impl Freeze for Target

§

impl Send for Target

§

impl Sync for Target

§

impl Unpin for Target

§

impl UnsafeUnpin for Target

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.