Skip to main content

MessageWriter

Struct MessageWriter 

Source
pub struct MessageWriter<'w, M>
where M: Message,
{ /* private fields */ }
Expand description

Writes Messages of type T.

This system parameter takes exclusive access to the Messages<T> resource, so a system cannot also have a MessageReader parameter of the same type. If you need to both read and write messages of the same type, use MessageMutator.

§Usage

MessageWriters are usually declared as a SystemParam.


#[derive(Message)]
pub struct MyMessage(String); // Custom message type.
fn my_system(mut writer: MessageWriter<MyMessage>) {
    writer.write(MyMessage("My custom payload!".to_string()));
}

§Concurrency

MessageWriter param has ResMut<Messages<T>> inside. So two systems declaring MessageWriter<T> params for the same message type won’t be executed concurrently.

§Untyped messages

MessageWriter can only write messages of one specific type, which must be known at compile-time. This is not a problem most of the time, but you may find a situation where you cannot know ahead of time every kind of message you’ll need to write. In this case, you can use the “type-erased message” pattern.

fn write_untyped(mut commands: Commands) {
    // Write a message of a specific type without having to declare that
    // type as a SystemParam.
    //
    // Effectively, we're just moving the type parameter from the /type/ to the /method/,
    // which allows one to do all kinds of clever things with type erasure, such as sending
    // custom messages to unknown 3rd party plugins (modding API).
    //
    // NOTE: the message won't actually be sent until commands get applied during
    // apply_deferred.
    commands.queue(|w: &mut World| {
        w.write_message(MyMessage);
    });
}

Note that this is considered non-idiomatic, and should only be used when MessageWriter will not work.

Implementations§

Source§

impl<'w, M> MessageWriter<'w, M>
where M: Message,

Source

pub fn write(&mut self, message: M) -> MessageId<M>

Writes an message, which can later be read by MessageReaders. This method returns the ID of the written message.

See Messages for details.

Examples found in repository?
examples/remote/app_under_test.rs (line 50)
48fn on_button_click(_click: On<PointerClick>, mut exit: MessageWriter<AppExit>) {
49    info!("Button pressed!");
50    exit.write(AppExit::Success);
51}
More examples
Hide additional examples
examples/app/custom_loop.rs (line 38)
36fn exit_system(input: Res<Input>, mut app_exit_writer: MessageWriter<AppExit>) {
37    if input.0 == "exit" {
38        app_exit_writer.write(AppExit::Success);
39    }
40}
examples/ecs/extraction.rs (line 108)
106fn trigger_extraction(mut writer: MessageWriter<ExtractMessage>, keys: Res<ButtonInput<KeyCode>>) {
107    if keys.pressed(KeyCode::Space) {
108        writer.write(ExtractMessage);
109    }
110}
examples/async_tasks/external_source_external_thread.rs (line 49)
47fn read_stream(receiver: Res<StreamReceiver>, mut events: MessageWriter<StreamMessage>) {
48    for from_stream in receiver.try_iter() {
49        events.write(StreamMessage(from_stream));
50    }
51}
examples/ecs/message.rs (line 47)
40fn deal_damage_over_time(
41    time: Res<Time>,
42    mut state: ResMut<DamageTimer>,
43    mut deal_damage_writer: MessageWriter<DealDamage>,
44) {
45    if state.tick(time.delta()).is_finished() {
46        // Messages can be sent with 'write' and constructed just like any other object.
47        deal_damage_writer.write(DealDamage { amount: 10 });
48    }
49}
50
51// This system both reads and writes `DealDamage` messages.
52//
53// Trying to do this with a `MessageReader` and a `MessageWriter` will fail with conflicts,
54// since they both use the same underlying resource.
55// Instead, you may use a `MessageMutator`, which allows both reading and writing.
56fn apply_extra_damage(mut dmg_messages: MessageMutator<DealDamage>) {
57    let mut extra = Vec::new();
58    for message in dmg_messages.read() {
59        if message.amount >= 10 {
60            extra.push(DealDamage {
61                amount: message.amount / 10,
62            });
63        }
64    }
65    // Note that this system will read messages it wrote itself!
66    // These are written after the `read()`, so they will be read the next time it runs.
67    for message in extra {
68        dmg_messages.write(message);
69    }
70}
71
72// This system mutates the 'DealDamage' messages to apply some armor value
73// It also sends an 'ArmorBlockedDamage' message if the value of 'DealDamage' is zero
74//
75// Messages are mutated using an 'MessageMutator<T>' by calling 'read'. This returns an iterator
76// over all the &mut T that this system has not read yet. Note, you can have multiple
77// 'MessageReader', 'MessageWriter', and 'MessageMutator' in a given system, as long as the types (T) are different.
78fn apply_armor_to_damage(
79    mut dmg_messages: MessageMutator<DealDamage>,
80    mut armor_messages: MessageWriter<ArmorBlockedDamage>,
81) {
82    for message in dmg_messages.read() {
83        message.amount -= 1;
84        if message.amount <= 0 {
85            // Zero-sized messages can also be sent with 'send'
86            armor_messages.write(ArmorBlockedDamage);
87        }
88    }
89}
examples/2d/dynamic_mip_generation.rs (line 316)
305fn setup(
306    mut commands: Commands,
307    mut regenerate_image_message_writer: MessageWriter<RegenerateImage>,
308) {
309    // Spawn the camera.
310    commands.spawn(Camera2d);
311
312    // Spawn the UI widgets at the bottom of the window.
313    spawn_ui(&mut commands);
314
315    // Schedule the image to be generated.
316    regenerate_image_message_writer.write(RegenerateImage);
317}
318
319/// Spawns the UI widgets at the bottom of the window.
320fn spawn_ui(commands: &mut Commands) {
321    commands.spawn_scene(bsn! {
322        @main_ui_node_scene()
323        Children [
324            // Spawn the "Regenerate Top Mip Level" button.
325            @FeathersButton {
326                @caption: bsn! { @caption("Regenerate Top Mip Level") }
327            }
328            RegenerateTopMipLevelButton
329            Node {
330                justify_content: JustifyContent::Center,
331                align_items: AlignItems::Center,
332            }
333            BackgroundColor(Color::BLACK)
334            --
335            // Spawn the "Mip Generation" switch that allows the user to toggle
336            // mip generation on and off.
337            @feathers_option_buttons(
338                "Mip Generation",
339                &[
340                    (
341                        EnableMipGeneration::On,
342                        "On"
343                    ),
344                    (
345                        EnableMipGeneration::Off,
346                        "Off"
347                    ),
348                ], 0
349            )
350            --
351            // Spawn the "Image Width" control that allows the user to set the
352            // width of the image.
353            @feathers_option_buttons(
354                "Image Width",
355                &[
356                    (ImageSizeSetting::ImageWidth(ImageSize::Size240), "240"),
357                    (ImageSizeSetting::ImageWidth(ImageSize::Size480), "480"),
358                    (ImageSizeSetting::ImageWidth(ImageSize::Size640), "640"),
359                    (ImageSizeSetting::ImageWidth(ImageSize::Size1080), "1080"),
360                    (ImageSizeSetting::ImageWidth(ImageSize::Size1920), "1920"),
361                ],
362                2
363            )
364            --
365            // Spawn the "Image Height" control that allows the user to set the
366            // height of the image.
367            @feathers_option_buttons(
368                "Image Height",
369                &[
370                    (ImageSizeSetting::ImageHeight(ImageSize::Size240), "240"),
371                    (ImageSizeSetting::ImageHeight(ImageSize::Size480), "480"),
372                    (ImageSizeSetting::ImageHeight(ImageSize::Size640), "640"),
373                    (ImageSizeSetting::ImageHeight(ImageSize::Size1080), "1080"),
374                    (ImageSizeSetting::ImageHeight(ImageSize::Size1920), "1920"),
375                ],
376                1
377            )
378        ]
379    });
380}
381
382impl MipmapSizeIterator {
383    /// Creates a [`MipmapSizeIterator`] corresponding to the size of the image
384    /// currently being displayed.
385    fn new(app_status: &AppStatus) -> MipmapSizeIterator {
386        MipmapSizeIterator {
387            size: Some(app_status.image_size_u32()),
388        }
389    }
390}
391
392impl Iterator for MipmapSizeIterator {
393    type Item = UVec2;
394
395    fn next(&mut self) -> Option<Self::Item> {
396        // The size of mipmap level N + 1 is equal to half the size of mipmap
397        // level N, rounding down, except that the size can never go below 1
398        // pixel on either axis.
399        let result = self.size;
400        if let Some(size) = self.size {
401            self.size = if size == UVec2::splat(1) {
402                None
403            } else {
404                Some((size / 2).max(UVec2::splat(1)))
405            };
406        }
407        result
408    }
409}
410
411/// Updates the size of the image on the left side of the window each frame.
412///
413/// Resizing the image every frame effectively cycles through all the image's
414/// mipmap levels, demonstrating the difference between the presence of mipmap
415/// levels and their absence.
416fn animate_image_scale(
417    mut animated_images_query: Query<&mut Transform, With<AnimatedImage>>,
418    windows_query: Query<&Window, With<PrimaryWindow>>,
419    app_status: Res<AppStatus>,
420    time: Res<Time>,
421) {
422    let window_size = windows_query.iter().next().unwrap().size();
423    let animated_mesh_size = app_status.animated_mesh_size(window_size);
424
425    for mut animated_image_transform in &mut animated_images_query {
426        animated_image_transform.scale =
427            animated_mesh_size.extend(1.0) * triangle_wave(time.elapsed_secs(), ANIMATION_PERIOD);
428    }
429}
430
431/// Evaluates a [triangle wave] with the given wavelength.
432///
433/// This is used as part of [`animate_image_scale`], to derive the scale from
434/// the current elapsed time.
435///
436/// [triangle wave]: https://en.wikipedia.org/wiki/Triangle_wave#Definition
437fn triangle_wave(time: f32, wavelength: f32) -> f32 {
438    2.0 * ops::abs(time / wavelength - ops::floor(time / wavelength + 0.5))
439}
440
441/// Adds the top mipmap level of the image to [`MipGenerationJobs`].
442///
443/// Note that this must run in the render world, not the main world, as
444/// [`MipGenerationJobs`] is a resource that exists in the former. Consequently,
445/// it must use [`Extract`] to access main world resources.
446fn extract_mipmap_source_image(
447    mipmap_source_image: Extract<Res<MipmapSourceImage>>,
448    app_status: Extract<Res<AppStatus>>,
449    mut mip_generation_jobs: ResMut<MipGenerationJobs>,
450) {
451    if app_status.enable_mip_generation == EnableMipGeneration::On {
452        mip_generation_jobs.add(MIP_GENERATION_PHASE_ID, mipmap_source_image.id());
453    }
454}
455
456/// Handles the button activation of the `RegenerateTopMipLevelButton`.
457fn handle_regenerate_top_mip_level_activate(
458    event: On<Activate>,
459    q: Query<(), With<RegenerateTopMipLevelButton>>,
460    mut regenerate_image_message_writer: MessageWriter<RegenerateImage>,
461) {
462    if q.contains(event.entity) {
463        // Schedule the image to be regenerated.
464        regenerate_image_message_writer.write(RegenerateImage);
465    }
466}
467
468/// Handles a request from the user to change the enable mip generation setting via the UI.
469fn handle_enable_mip_generation_change(
470    event: On<ValueChange<Entity>>,
471    new_value_query: Query<&RadioButtonOptionValue<EnableMipGeneration>>,
472    mut app_status: ResMut<AppStatus>,
473) {
474    let Ok(RadioButtonOptionValue(enable_mip)) = new_value_query.get(event.value) else {
475        return;
476    };
477    app_status.enable_mip_generation = *enable_mip;
478
479    // Enabling mip generation does not trigger a request to regenerate the image.
480}
481
482/// Handles a request from the user to change the image size via the UI.
483fn handle_image_size_setting_change(
484    event: On<ValueChange<Entity>>,
485    new_value_query: Query<&RadioButtonOptionValue<ImageSizeSetting>>,
486    mut app_status: ResMut<AppStatus>,
487    mut regenerate_image_message_writer: MessageWriter<RegenerateImage>,
488) {
489    let Ok(RadioButtonOptionValue(size_setting)) = new_value_query.get(event.value) else {
490        return;
491    };
492
493    match *size_setting {
494        ImageSizeSetting::ImageWidth(image_size) => app_status.image_width = image_size,
495        ImageSizeSetting::ImageHeight(image_size) => app_status.image_height = image_size,
496    }
497
498    // Schedule the image to be regenerated.
499    regenerate_image_message_writer.write(RegenerateImage);
500}
501
502/// Handles resize events for the window.
503///
504/// Resizing the window invalidates the image and repositions all image views.
505/// (Regenerating the image isn't strictly necessary, but it's simplest to have
506/// a single function that both regenerates the image and recreates the image
507/// views.)
508fn handle_window_resize_events(
509    mut events: MessageReader<WindowResized>,
510    mut regenerate_image_message_writer: MessageWriter<RegenerateImage>,
511) {
512    for _ in events.read() {
513        regenerate_image_message_writer.write(RegenerateImage);
514    }
515}
Source

pub fn write_batch( &mut self, messages: impl IntoIterator<Item = M>, ) -> WriteBatchIds<M> ⓘ

Writes a list of messages all at once, which can later be read by MessageReaders. This is more efficient than writing each message individually. This method returns the IDs of the written messages.

See Messages for details.

Examples found in repository?
examples/app/log_layers_ecs.rs (line 58)
53fn transfer_log_messages(
54    receiver: NonSend<CapturedLogMessages>,
55    mut message_writer: MessageWriter<LogMessage>,
56) {
57    // Make sure to use `try_iter()` and not `iter()` to prevent blocking.
58    message_writer.write_batch(receiver.try_iter());
59}
Source

pub fn write_default(&mut self) -> MessageId<M>
where M: Default,

Writes the default value of the message. Useful when the message is an empty struct. This method returns the ID of the written message.

See Messages for details.

Examples found in repository?
examples/ecs/message.rs (line 105)
97fn apply_damage_to_health(
98    mut deal_damage_reader: MessageReader<DealDamage>,
99    mut damaged_received_writer: MessageWriter<DamageReceived>,
100) {
101    for deal_damage in deal_damage_reader.read() {
102        info!("Applying {} damage", deal_damage.amount);
103        if deal_damage.amount > 0 {
104            // Messages with a 'Default' implementation can be written with 'write_default'
105            damaged_received_writer.write_default();
106        }
107    }
108}

Trait Implementations§

Source§

impl<'w, 's, M> ReadOnlySystemParam for MessageWriter<'w, M>

Source§

impl<M> SystemParam for MessageWriter<'_, M>
where M: Message,

Source§

type State = FetchState<M>

Used to store data which persists across invocations of a system.
Source§

type Item<'w, 's> = MessageWriter<'w, M>

The item type returned when constructing this system param. The value of this associated type should be Self, instantiated with new lifetimes. Read more
Source§

fn init_state(world: &mut World) -> <MessageWriter<'_, M> as SystemParam>::State

Creates a new instance of this param’s State.
Source§

fn init_access( state: &<MessageWriter<'_, M> as SystemParam>::State, system_meta: &mut SystemMeta, system_access: &mut SystemAccess, world: &mut World, )

Registers any World access used by this SystemParam. Read more
Source§

fn apply( state: &mut <MessageWriter<'_, M> as SystemParam>::State, system_meta: &SystemMeta, world: &mut World, )

Applies any deferred mutations stored in this SystemParam’s state. This is used to apply Commands during ApplyDeferred.
Source§

fn queue( state: &mut <MessageWriter<'_, M> as SystemParam>::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )

Queues any deferred mutations to be applied at the next ApplyDeferred.
Source§

unsafe fn get_param<'w, 's>( state: &'s mut <MessageWriter<'_, M> as SystemParam>::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick, ) -> Result<<MessageWriter<'_, M> as SystemParam>::Item<'w, 's>, SystemParamValidationError>

Creates a parameter to be passed into a SystemParamFunction. Read more

Auto Trait Implementations§

§

impl<'w, M> !UnwindSafe for MessageWriter<'w, M>

§

impl<'w, M> Freeze for MessageWriter<'w, M>
where ResMut<'w, Messages<M>>: Freeze,

§

impl<'w, M> RefUnwindSafe for MessageWriter<'w, M>
where ResMut<'w, Messages<M>>: RefUnwindSafe,

§

impl<'w, M> Send for MessageWriter<'w, M>
where ResMut<'w, Messages<M>>: Send,

§

impl<'w, M> Sync for MessageWriter<'w, M>
where ResMut<'w, Messages<M>>: Sync,

§

impl<'w, M> Unpin for MessageWriter<'w, M>
where ResMut<'w, Messages<M>>: Unpin,

§

impl<'w, M> UnsafeUnpin for MessageWriter<'w, M>
where ResMut<'w, Messages<M>>: UnsafeUnpin,

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, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
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> Downcast for T
where T: Any,

Source§

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

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

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

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

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

Convert &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)

Convert &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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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, 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> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

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> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
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> Settings for T
where T: 'static + Send + Sync,

Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

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

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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