Skip to main content

EntityCapabilityProvider

Trait EntityCapabilityProvider 

pub trait EntityCapabilityProvider<T, C>: Send + Sync
where T: ?Sized,
{ // Required method fn provide( &self, host: &mut dyn ServerHost, entity: EntityRef, context: C, ) -> Option<Box<T>>; }
Expand description

What answers an entity capability for one entity type: given the entity and the lookup’s context (its EntityCapabilityKey’s C), its handler, or none to leave it to the next provider. A closure is one.

Required Methods§

fn provide( &self, host: &mut dyn ServerHost, entity: EntityRef, context: C, ) -> Option<Box<T>>

The handler for entity, asked with context, or none.

Trait Implementations§

§

impl Wire for Box<dyn EntityCapabilityProvider<dyn ResourceHandler<ItemResource>, ()>>

§

const MIN: usize = 8

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take( input: &mut Reader<'_>, ) -> Result<Box<dyn EntityCapabilityProvider<dyn ResourceHandler<ItemResource>, ()>>, WireError>

Decodes one value, leaving any following bytes for the caller.
§

impl Wire for Box<dyn EntityCapabilityProvider<dyn ResourceHandler<ItemResource>, Option<Direction>>>

§

const MIN: usize = 8

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take( input: &mut Reader<'_>, ) -> Result<Box<dyn EntityCapabilityProvider<dyn ResourceHandler<ItemResource>, Option<Direction>>>, WireError>

Decodes one value, leaving any following bytes for the caller.
§

impl Wire for Box<dyn EntityCapabilityProvider<dyn ResourceHandler<FluidResource>, Option<Direction>>>

§

const MIN: usize = 8

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take( input: &mut Reader<'_>, ) -> Result<Box<dyn EntityCapabilityProvider<dyn ResourceHandler<FluidResource>, Option<Direction>>>, WireError>

Decodes one value, leaving any following bytes for the caller.
§

impl Wire for Box<dyn EntityCapabilityProvider<dyn EnergyHandler, Option<Direction>>>

§

const MIN: usize = 8

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take( input: &mut Reader<'_>, ) -> Result<Box<dyn EntityCapabilityProvider<dyn EnergyHandler, Option<Direction>>>, WireError>

Decodes one value, leaving any following bytes for the caller.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

§

impl<T, C, F> EntityCapabilityProvider<T, C> for F
where F: Fn(&mut dyn ServerHost, EntityRef, C) -> Option<Box<T>> + Send + Sync, T: ?Sized,