Skip to main content

FunctionSystem

Struct FunctionSystem 

Source
pub struct FunctionSystem<Marker, F>
where F: SystemParamFunction<Marker>,
{ /* private fields */ }
Expand description

A system that wraps a function and its cached parameter state.

FunctionSystem stores:

  • The function to call
  • Cached state for each parameter
  • Metadata (name, access patterns)

This type is created automatically when you call .into_system() on a function. You typically don’t construct it directly.

§Type Parameters

  • Marker: A type-level marker to distinguish different function arities
  • F: The function type

§Example

use goud_engine::ecs::{World, Component};
use goud_engine::ecs::system::{IntoSystem, BoxedSystem};

fn my_system() {
    println!("Hello from system!");
}

let boxed: BoxedSystem = my_system.into_system();
assert_eq!(boxed.name(), "my_system");

Implementations§

Source§

impl<Marker, F> FunctionSystem<Marker, F>
where F: SystemParamFunction<Marker>,

Source

pub fn new(func: F) -> Self

Creates a new function system from a function.

The state is initialized lazily on the first run.

§Arguments
  • func - The function to wrap
Source

pub fn with_name(self, name: impl Into<Cow<'static, str>>) -> Self

Sets a custom name for this system.

By default, the name is derived from the function’s type name.

§Arguments
  • name - The new name for the system

Trait Implementations§

Source§

impl<Marker, F> Debug for FunctionSystem<Marker, F>
where F: SystemParamFunction<Marker>,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<Marker, F> System for FunctionSystem<Marker, F>
where Marker: 'static, F: SystemParamFunction<Marker> + Send + 'static, F::State: Send + Sync,

Source§

fn name(&self) -> &'static str

Returns the name of this system. Read more
Source§

fn component_access(&self) -> Access

Returns the component access pattern for this system. Read more
Source§

fn initialize(&mut self, world: &mut World)

Called once when the system is first added to a scheduler. Read more
Source§

fn run(&mut self, world: &mut World)

Runs the system on the given world. Read more
Source§

fn is_read_only(&self) -> bool

Returns true if this system only reads data. Read more
Source§

fn should_run(&self, _world: &World) -> bool

Returns whether this system should run. Read more

Auto Trait Implementations§

§

impl<Marker, F> Freeze for FunctionSystem<Marker, F>
where F: Freeze, <F as SystemParamFunction<Marker>>::State: Freeze,

§

impl<Marker, F> RefUnwindSafe for FunctionSystem<Marker, F>

§

impl<Marker, F> Send for FunctionSystem<Marker, F>

§

impl<Marker, F> Sync for FunctionSystem<Marker, F>
where F: Sync,

§

impl<Marker, F> Unpin for FunctionSystem<Marker, F>
where F: Unpin, <F as SystemParamFunction<Marker>>::State: Unpin,

§

impl<Marker, F> UnsafeUnpin for FunctionSystem<Marker, F>
where F: UnsafeUnpin, <F as SystemParamFunction<Marker>>::State: UnsafeUnpin,

§

impl<Marker, F> UnwindSafe for FunctionSystem<Marker, F>
where F: UnwindSafe, <F as SystemParamFunction<Marker>>::State: UnwindSafe,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<S> IntoSystem for S
where S: System + 'static,

Source§

type System = S

The concrete system type this converts to.
Source§

fn into_system(self) -> BoxedSystem

Converts this into a system.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

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

Source§

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