Skip to main content

ScriptComponentRegistry

Struct ScriptComponentRegistry 

Source
pub struct ScriptComponentRegistry { /* private fields */ }
Expand description

A registry of dynamically registered script components, events, exports and system sets

Implementations§

Source§

impl ScriptComponentRegistry

Source

pub fn register(&mut self, info: DynamicComponentInfo)

Registers a dynamic script component, possibly overwriting an existing one

Source

pub fn get(&self, path: &str) -> Option<&DynamicComponentInfo>

Gets a dynamic script component by its full path, i.e. script.game.Enemy

Source

pub fn find(&self, path: &str) -> Option<&DynamicComponentInfo>

Gets a dynamic script component by its full path (i.e. script.game.Enemy).

Source

pub fn generation(&self) -> u64

A counter which changes whenever a component is registered.

Lookups of existing registrations do not change it.

Source

pub fn iter_components(&self) -> impl Iterator<Item = &DynamicComponentInfo>

Iterates over all registered script components

Source

pub fn register_event(&mut self, registration: ScriptEventRegistration)

Registers a script event, possibly overwriting an existing one

Source

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

Gets a script event by its full path

Source

pub fn register_export( &mut self, export: ScriptExport, ) -> Result<(), InteropError>

Registers a function exported by a script.

Exporting the same path again from the same script replaces the export (i.e. when a script runs again), exporting a path another script exported, or one used by a component or event, is an error.

Source

pub fn remove_exports_of(&mut self, owner: &ScriptAttachment) -> usize

Removes all exports of the given script, returns how many there were

Source

pub fn get_export(&self, path: &str) -> Option<&ScriptExport>

Gets an export by its full path

Source

pub fn iter_exports_in<'a>( &'a self, namespace: &'a str, ) -> impl Iterator<Item = &'a ScriptExport>

Iterates over the exports of the given namespace

Source

pub fn iter_events_in<'a>( &'a self, namespace: &'a str, ) -> impl Iterator<Item = (&'a str, &'a ScriptEventRegistration)>

Iterates over the script events of the given namespace, with their names within it

Source

pub fn export_and_event_namespaces(&self) -> impl Iterator<Item = &str>

The namespaces with at least one export, event or system set, in no particular order, possibly repeated

Source

pub fn register_system_set(&mut self, path: String, owner: ScriptAttachment)

Registers a system set of a script by its full path, i.e. script.game.ai, possibly replacing its owner

Source

pub fn get_system_set_owner(&self, path: &str) -> Option<&ScriptAttachment>

The script which registered the system set with the given full path

Source

pub fn remove_system_sets_of(&mut self, owner: &ScriptAttachment) -> usize

Removes all system sets registered by the given script, returns how many there were.

The sets stay in the schedules, systems can still be in and ordered against them.

Source

pub fn iter_system_sets_in<'a>( &'a self, namespace: &'a str, ) -> impl Iterator<Item = (&'a str, &'a str)>

Iterates over the full paths and names of the system sets registered into the given namespace

Trait Implementations§

Source§

impl Default for ScriptComponentRegistry

Source§

fn default() -> ScriptComponentRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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

Source§

impl<T> Context for T
where T: 'static + Send + Any,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

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

Source§

impl<T> Runtime for T
where T: Default + 'static + Send + Sync,

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

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.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more