Struct Builder

Source
pub struct Builder<'a> { /* private fields */ }
Expand description

Builder for the Dispatcher.

§Barriers

Barriers are a way of sequentializing parts of the system execution. See add_barrier()/with_barrier().

§Examples

This is how you create a dispatcher with a shared thread pool:

let dispatcher = Dispatcher::builder()
    .with(system_a, "a", &[])
    .unwrap()
    .with(system_b, "b", &["a"])
    .unwrap() // b depends on a
    .with(system_c, "c", &["a"])
    .unwrap() // c also depends on a
    .with(system_d, "d", &[])
    .unwrap()
    .with(system_e, "e", &["c", "d"])
    .unwrap() // e executes after c and d are finished
    .build();

Systems can be conditionally added by using the add_ functions:

let mut builder = Dispatcher::builder().with(system_a, "a", &[]).unwrap();

if b_enabled {
    builder.add(system_b, "b", &[]).unwrap();
}

let dispatcher = builder.build();

Implementations§

Source§

impl<'a> Builder<'a>

Source

pub fn new(world: Option<&'a mut World>) -> Self

Source

pub fn build(self) -> Dispatcher

Builds the Dispatcher.

This method will precompute useful information in order to speed up dispatching.

Source

pub fn with<S>( self, system: S, name: &str, dependencies: &[&str], ) -> Result<Self, Error>
where S: for<'s> System<'s> + Send + 'static,

Adds a new system with a given name and a list of dependencies. Please note that the dependency should be added before you add the depending system.

If you want to register systems which can not be specified as dependencies, you can use "" as their name, which will not panic (using another name twice will).

Same as add(), but returns self to enable method chaining.

Source

pub fn add<S>( &mut self, system: S, name: &str, dependencies: &[&str], ) -> Result<&mut Self, Error>
where S: for<'s> System<'s> + Send + 'static,

Adds a new system with a given name and a list of dependencies. Please note that the dependency should be added before you add the depending system.

If you want to register systems which can not be specified as dependencies, you can use "" as their name, which will not panic (using another name twice will).

Source

pub fn with_async<S>( self, system: S, name: &str, dependencies: &[&str], ) -> Result<Self, Error>
where S: for<'s> AsyncSystem<'s> + Send + 'static,

Adds a new asynchronous system with a given name and a list of dependencies. Please note that the dependency should be added before you add the depending system.

If you want to register systems which can not be specified as dependencies, you can use "" as their name, which will not panic (using another name twice will).

Same as add(), but returns self to enable method chaining.

Source

pub fn add_async<S>( &mut self, system: S, name: &str, dependencies: &[&str], ) -> Result<&mut Self, Error>
where S: for<'s> AsyncSystem<'s> + Send + 'static,

Adds a new asynchronous system with a given name and a list of dependencies. Please note that the dependency should be added before you add the depending system.

If you want to register systems which can not be specified as dependencies, you can use "" as their name, which will not panic (using another name twice will).

Source

pub fn with_local<S>( self, system: S, name: &str, dependencies: &[&str], ) -> Result<Self, Error>
where S: for<'s> System<'s> + 'static,

Adds a new thread local system.

Please only use this if your struct is not Send and Sync.

Thread-local systems are dispatched in-order.

Same as [Dispatcher::builder()::add_local], but returns self to enable method chaining.

Source

pub fn add_local<S>( &mut self, system: S, name: &str, dependencies: &[&str], ) -> Result<&mut Self, Error>
where S: for<'s> System<'s> + 'static,

Adds a new thread local system.

Please only use this if your struct is not Send and Sync.

Thread-local systems are dispatched in-order.

Source

pub fn with_local_async<S>( self, system: S, name: &str, dependencies: &[&str], ) -> Result<Self, Error>
where S: for<'s> AsyncSystem<'s> + 'static,

Adds a new thread local asynchronous system.

Please only use this if your struct is not Send and Sync.

Thread-local systems are dispatched in-order.

Same as [Dispatcher::builder()::add_local], but returns self to enable method chaining.

Source

pub fn add_local_async<S>( &mut self, system: S, name: &str, dependencies: &[&str], ) -> Result<&mut Self, Error>
where S: for<'s> AsyncSystem<'s> + 'static,

Adds a new thread local asynchronous system.

Please only use this if your struct is not Send and Sync.

Thread-local systems are dispatched in-order.

Auto Trait Implementations§

§

impl<'a> Freeze for Builder<'a>

§

impl<'a> !RefUnwindSafe for Builder<'a>

§

impl<'a> !Send for Builder<'a>

§

impl<'a> !Sync for Builder<'a>

§

impl<'a> Unpin for Builder<'a>

§

impl<'a> !UnwindSafe for Builder<'a>

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> Any for T
where T: Any,

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.